I dont have an actual Android phone, and i want to test Alarm, but i dont know if its the code that has error, or the emulator doesnt do the way like an actual phone in terms of booting.
the Autostart Code is from here: Alarm Manager Example
The code doesnt give me error, the simple alarm manager and service is OK, but the autostart of the alarm is not working, i hope its only on the emu, wish it will work in an actual phone. The code below is from the above-mentioned thread, and it also the one that i uses.. i'd put it because maybe the code are the problems
Manifest
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"></uses-permission>
...
<receiver android:name=".AutoStart">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"></action>
</intent-filter>
</receiver>
...
And this is the on-boot trigger
package YourPackage;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
public class AutoStart extends BroadcastReceiver
{
Alarm alarm = new Alarm();
@Override
public void onReceive(Context context, Intent intent)
{
if (intent.getAction().equals("android.intent.action.BOOT_COMPLETED"))
{
alarm.SetAlarm(context);
}
}
}