可能重复:
window already focused - ignoring focus gain of com.android.internal.view
我使用通知通知用户他/她是否有网站消息,当用户点击通知时,它会关注MessageActivity以显示消息。
除了一种情况之外它工作正常:如果用户点击新通知时当前关注的Activity是MessageActivity,则控制台将打印已经聚焦的窗口,忽略焦点增益:com.android.internal.view.IInputMethodClient $存根$ Proxy ,没有任何事情发生。
请帮帮我。 MessageActivity的launchmode是singleTask。
Notification notification = new Notification();
notification.icon = R.drawable.msg;
notification.tickerText = content
notification.defaults=Notification.DEFAULT_SOUND;
notification.audioStreamType= android.media.AudioManager.ADJUST_LOWER;
notification.when=System.currentTimeMillis();
Intent notificationIntent = new Intent(MainActivity.this, MessageActivity.class);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
notificationIntent.addCategory(Intent.CATEGORY_LAUNCHER);
notificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
notificationIntent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
notificationIntent.setAction(System.currentTimeMillis());
notificationIntent.putExtra("msgid", msgid);
PendingIntent pendingIntent = PendingIntent.getActivity(AutoActivity.this, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
notification.setLatestEventInfo(MainActivity.this, "get a message", "test", pendingIntent);
notification.flags |= Notification.FLAG_AUTO_CANCEL;
manager.notify(msgid, notification);