I have broadcast which is recieved on system boot as well as by an intent. This broadcast is to set alarm.
Intent intent = new Intent();
intent.setAction("recievers.BroadCastBootRec");
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
getActivity().sendBroadcast(intent);
My Broadcast class :
@Override
public void onReceive(Context context, Intent intent) {
c = context;
Log.d("HirakDebug", "BroadCast Recieved");
getDatesFromDatabase();
getDateDifference();
setAlarmI();
}
Manifest.xml
<receiver android:name=".recievers.BroadCastBootRec"
android:label="BootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</receiver>
Anonymous User
17-Nov-2014You have to register two actions and to make things clear. android:name is the Class name of the receiver you had written, not the action. So, for the below receiver your receiver class name will be "BroadCastBootRec"
The android system will inform your receiver when ever an action BOOT_COMPLETED andcom.example.BroadCastBootRec is triggered
public class BroadCastBootRec extends BroadcastReceiver