저는 정말 내 안드로이드 응용 프로그램으로 전진하고 있습니다. 나는 onDestroy() and onPause()
루틴을 구현할 수 있었다.Android SDK. 새로운 인스턴스를 시작하지 않고 NOTIFICATION_SERVICE을 (를) 다시 시작하십시오.
나는 또한 알림 표시 줄/작업 메뉴에 제목과 본문이있는 아이콘을 배치하기 위해 Android의 알림 서비스를 사용할 수있었습니다.
이 알림 서비스의 유일한 문제점은 내 안드로이드 앱이 이미 실행 중이고 onPause()
기능이 super.onPause(); moveTaskToBack(true);
으로 시작된 경우 사용자가 알림을 탭하면 내 앱의 새로운 인스턴스가 나타납니다.
사용자가 새 인스턴스와 상호 작용하면 배경 버전이 이미 실행되어 충돌을 일으키기 때문에 프로그램이 중단됩니다. 내가 bringTaskToFront(this)
옵션의 일종이 될 수와 onResume()
보고 있었다
String ns = Context.NOTIFICATION_SERVICE;
NotificationManager mNotificatonManager = (NotificationManager) getSystemService(ns);
int icon = R.drawable.ic_launcher;
CharSequence tickerText = "app name";
long when = System.currentTimeMillis();
CharSequence contentTitle = "app title";
CharSequence contentText = "text";
Intent notificationIntent = new Intent(this, SuperMicProActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
final int signed = 1;
mNotificatonManager.notify(signed, notification);
:
여기 내 응용 프로그램의 이미 실행중인 버전이 코드의 모양을 만드는 데 도움이 필요, 내 알림 코드입니다. 이것이 존재합니까?
감사합니다.
걱정하지 마라. 단순히 Manifest 파일을 열고 내 '