Note that there are some explanatory texts on larger screens.

plurals
  1. POPendingIntent sent from a notication
    primarykey
    data
    text
    <p>What im trying to accomplish is to send a notification through the notification manager that once clicked will do something in the application only if its currently running. i have tried to use:</p> <pre><code>notification.contentIntent = PendingIntent.getActivity(this, nNotificationCounter, Someintent, PendingIntent.FLAG_NO_CREATE) </code></pre> <p>Which allways caused an exception once trying to use the notify. I switched to:</p> <pre><code>Notification notification = new Notification(icon, tickerText, when); RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.some_notification); contentView.setTextViewText(R.id.title, sTitle); contentView.setTextViewText(R.id.text, sText); notification.contentView = contentView; notification.defaults |= Notification.DEFAULT_SOUND; notification.number = nNotificationCounter; Intent notificationIntent = new Intent(this, MainWindow.class).setAction(ACTION_RESET_MESSGE_COUNTER); notification.contentIntent = PendingIntent.getBroadcast(this, nNotificationCounter, notificationIntent, 0); </code></pre> <p>and although this code doesn't cause an exception. it doesnt call my BroadcastReceiver which is defined as follows:</p> <pre><code>public class IncomingReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { if (intent.getAction().equals(ACTION_RESET_MESSGE_COUNTER)) { System.out.println("GOT THE INTENT"); return; } } } </code></pre> <p>and set in the onCreate:</p> <pre><code>IntentFilter filter = new IntentFilter(ACTION_RESET_MESSGE_COUNTER); IncomingReceiver receiver = new IncomingReceiver(); context.registerReceiver(receiver, filter); </code></pre> <p>Does anyone see something wrong with the code? Or how would i go about to get messages when the notification is clicked, but not create any activity if it isn't already created.</p> <p>edit: added the intent creation and notification creation.</p> <p>Thanks, Tom</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload