I start the service like that
Intent service1 = new Intent(context, MyService.class); service1.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK|Intent.FLAG_ACTIVITY_CLEAR_TOP| Intent.FLAG_ACTIVITY_NEW_TASK);
context.startService(service1);
Here is my onstart in service class
public void onStart(Intent intent, int startid) {
player.start();
this.getApplicationContext();
mManager = (NotificationManager) this.getApplicationContext()
.getSystemService(Context.NOTIFICATION_SERVICE);
Intent intent1 = new Intent(this.getApplicationContext(), Alarm.class);
Notification notification = new Notification(R.drawable.icon,
"Phone start ringing!", System.currentTimeMillis());
intent1.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP
| Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingNotificationIntent = PendingIntent.getActivity(
this.getApplicationContext(), 0, intent1,
PendingIntent.FLAG_UPDATE_CURRENT);
notification.flags |= Notification.FLAG_HIGH_PRIORITY;
notification.setLatestEventInfo(this.getApplicationContext(),
"Ping My Android", "Confirm Your identity!",
pendingNotificationIntent);
mManager.notify(125, notification);
and here is the manifest
<service
android:name=".MyService"
android:enabled="true" />
the problem is when i kill my application from task manager the service take 2 to 3 seconds and restart again and my alarm is restart from start.