Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you use pending intents with localbroadcasts?

Tags:

I am interested in using pending intents with local broadcasts. To make myself clear, I am using the following for registering receivers and sending broadcast: android.support.v4.content.LocalBroadcastManager.

I have a local broadcast receiver in a service which works. I am trying to send local broadcasts from a custom notification layout which includes click-able items.

The local broadcast receiver - just receives simple action intents. I was trying something like this to no avail:

Intent backintent = new Intent("GOTO_START_BROADCAST"); PendingIntent backIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, backintent, 0); RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.custom_notification); contentView.setOnClickPendingIntent(R.id.imageView1, backIntent); 
like image 776
Nims Avatar asked Apr 03 '13 14:04

Nims


1 Answers

I am interested in using pending intents with local broadcasts.

That is not possible.

The point behind a PendingIntent is to allow some other process to perform an action you request, such as sending a broadcast.

The point behind LocalBroadcastManager is to keep broadcast within your process.

Hence, a PendingIntent can issue a regular broadcast, but not one via LocalBroadcastManager.

like image 170
CommonsWare Avatar answered Sep 24 '22 08:09

CommonsWare