I am trying to start service using PendingIntent
. Notification
shows but on click of it onStartCommand
of service not working.
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(EasyTouchService.this,"my_channel_id_01");
Intent settingsIntent = new Intent(EasyTouchService.ACTION_SETTINGS);
settingsIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent settingsPendingIntent = PendingIntent.getService(EasyTouchService.this, 1, settingsIntent, PendingIntent.FLAG_UPDATE_CURRENT); //also tried o and some others
mBuilder.setSmallIcon(R.drawable.eight_ball_img);
mBuilder.setContentTitle(getString(R.string.app_name));
mBuilder.setContentText("Open Settings");
mBuilder.setAutoCancel(false);
mBuilder.addAction(android.R.drawable.ic_menu_close_clear_cancel, "Stop Service", stopPendingIntent);
mBuilder.addAction(android.R.drawable.ic_menu_rotate, "Show/Hide", hidePendingIntent);
mBuilder.setContentIntent(settingsPendingIntent);
mNotification = mBuilder.build();
// setUpAsForeground(message);
mNotification.flags |= Notification.FLAG_ONGOING_EVENT | Notification.FLAG_NO_CLEAR;
//updateNotification("Hide Pattern");
mNotification.tickerText = getString(R.string.app_name);
int NOTIFICATION_ID = 121125;
startForeground(NOTIFICATION_ID, mNotification);
What am i doing wrong?