4

Every One

Can i Get BroadcastReceiver for This Intent when i press home Key :

       Starting activity: Intent { act=android.intent.action.MAIN   cat=   [android.intent.category.HOME] flg=0x10200000 cmp=com.htc.launcher/.Launcher }

I don't want to Consider com.htc.luncher as it will we different for Other Android Device .

Here i my Simple Class For BroadcastReceiver :

 public class HomeBrodcast extends BroadcastReceiver{

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


 }

}

In Manifest :

  <receiver android:name="xxx.yyy.zzz.sss.HomeBrodcast">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"></action>
            <categary android:name="android.intent.category.HOME"/>
        </intent-filter>
    </receiver>

For Register BroadcastReceiver in My Activity :

          mHomeBrodcast=new HomeBrodcast();
      IntentFilter mHomeFilter=new IntentFilter("android.intent.action.MAIN");
      mHomeFilter.addCategory("android.intent.category.HOME");
      registerReceiver(mHomeBrodcast, mHomeFilter);

Now Problem is When After Start My Application i press Home Button Press and My Log Show Me this Intent :

  12-27 14:01:11.230: I/ActivityManager(123): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.HOME] flg=0x10200000 cmp=com.htc.launcher/.Launcher }

So My Goal is to get Receiver for This Intent But When i Debug i am not Getting Any Thing Some Thing Must me Wrong .What should be Problem in Getting This Intent BroadCast .

Herry
  • 7,037
  • 7
  • 50
  • 80

3 Answers3

2

spelling category right in the manifest should help :)

SoundsDangerous
  • 708
  • 6
  • 13
  • 1
    in fact I have the exact same code, with correct spelling, and my receiver never receive a thing – Kiwy Jun 15 '12 at 20:16
0

I do not think you can get that functionality, see https://groups.google.com/forum/#!topic/android-developers/fNTysSA8mWQ

Amilcar Andrade
  • 1,131
  • 9
  • 16
0

Android internally calls startActivity for starting the ACTION_MAIN registered component to start the launcher. Since you are registered with the receiver, It wont be get called unless it calls with sendBroadast. Hope it helps