There are some broadcast in android which you can't detect just declaring receiver with intent-filters in Android-Manifest.xml to detect them you need one active component service or activity which will register Custom broadcast receiver at run time as follows
MyReceiver br = new MyReceiver();
IntentFilter theFilter1 = new IntentFilter(Intent.ACTION_HEADSET_PLUG);
IntentFilter theFilter2 = new IntentFilter(Intent.ACTION_SCREEN_ON);
registerReceiver(br, theFilter1);
registerReceiver(br, theFilter2);
No comments:
Post a Comment