0

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.

user3765485
  • 69
  • 2
  • 9
  • Refer this link http://stackoverflow.com/questions/9093271/start-sticky-and-start-not-sticky – Rajaji subramanian Jun 28 '14 at 10:32
  • Can you please update my code ? because i already have tried to return Service.START_NOT_STICKY BUT IT NOT WORKING FOR ME servce keep restart after kill the application – user3765485 Jun 28 '14 at 10:42

0 Answers0