int icon = R.drawable.ic_launcher;
long when = System.currentTimeMillis();
NotificationManager notificationManager = (NotificationManager)
context.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(icon, message, when);
String title = context.getString(R.string.app_name);
//Intent notificationIntent = new Intent(context, MyActivity.class);
Intent notificationIntent = context.getPackageManager().getLaunchIntentForPackage("패키지명");
// set intent so it does not start a new activity
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP |
Intent.FLAG_ACTIVITY_SINGLE_TOP);
notificationIntent.putExtra("message",message);
PendingIntent intent =
PendingIntent.getActivity(context, 0, notificationIntent, 0);
notification.setLatestEventInfo(context, title, message, intent);
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notificationManager.notify(0, notification);
=======================================================================
Notification 띄우는 소스코드는 위와 같습니다.
상단 알림에 메세지가 뜨는데 그영역을 터치 하면 제 어플이 실행되게 처리했는데요.
여기서 문제는 어플이 이미 실행중인데도 재시작 돼버리네요.
만약 어플이 살아있다면 (home 키를 눌러서 최소화된 상태) 굳이 재실행 하지않고 마지막으로 띄웠던 액티비티 그대로를 보여줬음 하는데..
도움 부탁드립니다. (__)