1
서비스에서 알림을 보내려고하고 있는데, 그 것이 성공하면 (상태 표시 줄에 알림이 표시됩니다). 하지만 활동을보기 위해 알림을 클릭 한 후 - 모바일 홈 화면으로 돌아갑니다. 또한 디버깅 모드에서 activity의 "onCreate"메서드에 도달하지 못했다는 것을 알았습니다. 여기 서비스에서 알림이 작동하지만 작업이 시작되지 않았습니다.
의 코드 내 조각 : 서비스 코드 :NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
int icon = R.drawable.notificationicon;
CharSequence tickerText = "Hello";
long when = System.currentTimeMillis();
Notification notification = new Notification(icon, tickerText, when);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0,
new Intent(this, NotificationsActivity.class), 0);
notification.setLatestEventInfo(this, "My notification","Hello World!", pendingIntent);
notificationManager.notify(1, notification);
활동 코드 :
당신이 수신기/서비스 내에서startActivity
할 경우에
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(dialogLayout);
}
NotificationActivity 클래스가 AndroidManifest.xml에 정의되어 있습니까? (AndroidManifest를 붙여 넣을 수 있습니까?) –