I have the Problem that I created a Service which should be created when the AlarmManager wakes up. And actually it’s starting (onStartCommand is called, I see the toast), but same time in the log appears:
09-19 02:48:32.537: I/ActivityManager(1983): START {flg=0x4 cmp=com.my.app/.syncService.SyncService (has extras)} from pid -1
09-19 02:48:39.662: W/ActivityManager(1983): Unable to start service Intent { act=com.my.app.syncService.SyncService flg=0x4 (has extras) }: not found
Intent:
Intent intent = new Intent("com.my.app.syncService.SyncService");
PendingIntent pendingIntent = PendingIntent.getService(this, 12345, intent, PendingIntent.FLAG_CANCEL_CURRENT);
AlarmManager am = (AlarmManager)getSystemService(Activity.ALARM_SERVICE);
am.setInexactRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), 1000*30, pendingIntent);
my Service looks like this:
public class SyncService extends Service{
@Override
public void onCreate() {
Log.d("SyncService", "onCreate");
Log.d("SyncService", "onCreate");
Log.d("SyncService", "onCreate");
super.onCreate();
Toast.makeText(this, "Debug: SyncService created", Toast.LENGTH_LONG).show();
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Toast.makeText(this, "Debug: SyncService onStartCommand", Toast.LENGTH_LONG).show();
return super.onStartCommand(intent, flags, startId);
}
}
AndroidManifest:
<application>
...
<service android:enabled="true" android:name="com.my.app.syncService.SyncService"/>
</application>
Isn’t it a bit strange? The onCreate get’s only called once, which makes sense to me, but the rest?
I think you can try change this line
To
Here, the
contextdepends on where you create theAlarmManager