в моем приложении запускается фоновая служба, и из этой службы я хочу установить уведомление в строке состояния, что служба запущена, следующий код:
Context context = getApplicationContext();
String ns = Context.NOTIFICATION_SERVICE;
int icon = R.drawable.icon;
CharSequence tickerText = "Hello";
long when = System.currentTimeMillis();
Notification notification = new Notification(icon, tickerText, when);
CharSequence contentTitle = "My notification";
CharSequence contentText = "Hello World!";
Intent notificationIntent = new Intent(MyService.this, MyClass.class);
notificationIntent.setFlags( Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent contentIntent = PendingIntent.getActivity(this,0,notificationIntent,0);
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);
mNotificationManager.notify(1, notification);
Уведомление отображается в строке состояния, но когда я нажимаю, MyClass.class не запускается. И в журнале cat он показывает
«Окно обслуживания менеджера ввода уже сфокусировано, игнорируя фокус ...»
так что, пожалуйста, предоставьте решение.
спасибо заранее