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. Oops, I crashed the phone

The current version of Floating Image (version 2.5.0, code 36)
randomly crashes Nexus One phones. Obviously I'm looking into fixing
this problem, but I though it would be prudent for me to report this.
It's always a problem if you can crash the phone. As I'm working with
OpenGL I'm guessing this is the problem, as I'm working directly with
the hardware. When the phone crashes it hangs for a couple of minutes,
being very chatty in the log, and then reboots. I will post the log
after the next crash.

Not sure if this will be useful or not, but I thought I ought to
report it. :)

- Mark

-- 

2. vold issues

Hi All,

I am currently working on bringing up Froyo on a device on which we
are booting to the sdcard. U-Boot, kernel, and root filesystem are all
there on separate partitions.

We have a partition, /dev/block/mmcblk0p1, which has a FAT32
filesystem to be used as /mnt/sdcard. In Eclair, this worked fine. But
with the new vold, we find that it fails.

I'm using the Freescale i.MX51 platform, my vold.fstab looks like
this:

   dev_mount sdcard /mnt/sdcard auto /devices/platform/mxsdhci.0

I've also tried:

   dev_mount sdcard /mnt/sdcard auto /devices/platform/mxsdhci.0/
mmc_host/mmc0

   dev_mount sdcard /mnt/sdcard auto /devices/platform/mxsdhci.0/
mmc_host/mmc0/mmc0:b368

Niether of those worked either.

Here's the output I get while booting:

   I/Netd    ( 2041): Netd 1.0 starting
   I/Vold    ( 2040): Vold 2.1 (the revenge) firing up
   D/Vold    ( 2040): Volume sdcard state changing -1 (Initializing) -
   D/DirectVolume( 2040): Dv::diskIns - waiting for 6 partitions (mask
0x7e)
   D/Vold    ( 2040): Volume sdcard state changing 0 (No-Media) -> 2
(Pending)
   D/DirectVolume( 2040): Dv:partAdd: part_num = 1, minor = 1
   D/DirectVolume( 2040): Dv:partAdd: pending mask now = 0x7c
   D/DirectVolume( 2040): Dv:partAdd: part_num = 2, minor = 2
   D/DirectVolume( 2040): Dv:partAdd: pending mask now = 0x78
   D/DirectVolume( 2040): Dv:partAdd: part_num = 3, minor = 3
   D/DirectVolume( 2040): Dv:partAdd: pending mask now = 0x70
   D/DirectVolume( 2040): Dv:partAdd: part_num = 4, minor = 4
   D/DirectVolume( 2040): Dv:partAdd: pending mask now = 0x60
   D/DirectVolume( 2040): Dv:partAdd: part_num = 5, minor = 5
   D/DirectVolume( 2040): Dv:partAdd: pending mask now = 0x40
   D/DirectVolume( 2040): Dv:partAdd: part_num = 6, minor = 6
   D/DirectVolume( 2040): Dv:partAdd: pending mask now = 0x6

And here is some output from the vdc command line interface:

   # vdc volume list
   110 sdcard /mnt/sdcard 2
   200 Volumes listed.
   # vdc volume mount /mnt/sdcard
   405 volume operation failed (Device or resource busy)

I can manually mount the device using this command without any error:

   mount -t vfat /dev/block/mmcblk0p1 /mnt/sdcard

Any help with this would be appreciated.

Thanks,
Anthony

-- 
unsubscribe: android-porting+unsubscr...@googlegroups.com
website: 

3. Bluetooth headset connection establishment

4. HTC Sense Dutch Date Formatting

5. iPhone like tab

6. Emulator shortcomings regarding the touchscreen interaction

7. facing loading & binding oepngles texture in my Augmented reality program....