Broadcast receivers

by Raj » Wed, 18 Nov 2009 22:57:08 GMT


Sponsored Links
 Hi

I would like to add my own listeners to broadcast receiver so that
when different SMS arrive with different subjects, I can notify the
respective listeners.

@Override
        public void onReceive(Context context, Intent intent) {
                Bundle bundle = intent.getExtras();

                Object messages[] = (Object[]) bundle.get("pdus");
                SmsMessage smsMessage[] = new SmsMessage[messages.length];
                for (int n = 0; n < messages.length; n++) {
                smsMessage[n] = SmsMessage.createFromPdu((byte[]) messages[n]);
                }

Intent broadcast = new Intent(context,ApiKeyMessageListener.class);
                                
broadcast.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                                broadcast.putExtra("API_KEY", message);
                                context.startActivity(new Intent(broadcast));

--



Broadcast receivers

by Raj » Wed, 18 Nov 2009 22:57:11 GMT


 Hi

I would like to add my own listeners to broadcast receiver so that
when different SMS arrive with different subjects, I can notify the
respective listeners.

@Override
        public void onReceive(Context context, Intent intent) {
                Bundle bundle = intent.getExtras();

                Object messages[] = (Object[]) bundle.get("pdus");
                SmsMessage smsMessage[] = new SmsMessage[messages.length];
                for (int n = 0; n < messages.length; n++) {
                smsMessage[n] = SmsMessage.createFromPdu((byte[]) messages[n]);
                }

               Intent broadcast = new Intent
(context,ApiKeyMessageListener.class);
               broadcast.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
               broadcast.putExtra("API_KEY", message);
               context.startActivity(new Intent(broadcast));
       }

Basically I want to get reference to this BroadcastRecevier object and
add listeners to it.  How
do I get the object reference that is declared in AndroidManifest.xml

Or is there an alternative way to do this?

thanks
Raj

--


Sponsored Links


Broadcast Receivers

by pperotti » Thu, 22 Apr 2010 04:06:40 GMT


 Hi Everyone,

Can anyone give a hint if you know why there are some ACTIONS that do
not trigger their associated receivers when they are registered in the
manifest while they are received when they are register through
registerReceiver() ?

For instance, when I declare:

<receiver android:name=".MyReceiver">
    <intent-filter>
        <action android:name="android.intent.action.NEW_OUTGOING_CALL" />
    </intent-filter>
</receiver>

if the application is NOT running MyReceiver is never invoked.

But now, if I register the intent from inside a service, MyReceiver is
invoked properly.

Any tip will be appreciated.

Regards, Pablo

--



Broadcast Receivers

by Mark Murphy » Thu, 22 Apr 2010 04:38:38 GMT


 


Usually, it's for performance reasons.

Take your desired Intent, for example. ACTION_NEW_OUTGOING_CALL is
something the user is particularly paying attention to. If Android has
to fire off a bunch of processes, load up the receivers, and pass the
Intent to each, that's going to slow down how quickly Android is able to
place the call.

Another example is ACTION_BATTERY_CHANGED -- they don't want to fire up
a bunch of processes just to tell apps that the battery level changed.
After all, firing off all those processes and doing all that work might
decrease the battery level, requiring another round of
ACTION_BATTERY_CHANGED, which will either eventually drain the battery
or create a rupture in the space-time continuum. I get those two cases
confused a lot.

Sometimes, Intents that do not support manifest-registered receivers are
documented, sometimes not.

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com  |  http://twitter.com/commonsguy 

Android Training in US: 14-18 June 2010:  http://bignerdranch.com 

--



Other Threads

1. Whatsapp bikin battery boros

pemakaian Whatsapp bikin boros battery

ini bener ga sih?

kok tmn2 yg pake BB bilangnya gitu,
tp kalo buat saya ga ngerasa signifikan sih



- Legendroid

-- 
"

2. [WTA]inject xoom

Dear all,

Saya lagi nunggu xoom dari US nih...nah saya pengen tau apa aja yang
musti disiapin buat inject xoom? atau ada yang udah buat tutornya?

Trims

-- 
"

3. Long Press on Power Key with MonkeyRunner

4. touchScreen port

5. Keystore

6. Android sensor permissions

7. Google maps removing an individual overlayitem and saving it