사용자가 알림 창에서 푸시 알림을 클릭하여 활동/앱을 시작했는지 알 수있는 플래그와 매개 변수가 있는지 알고 싶습니다. . C2DMReceiver.java앱이 푸시 알림을 클릭하여 실행되었는지 알 수있는 방법
에서내 코드
Context context = getApplicationContext();
PackageManager manager = context.getPackageManager();
Intent notificationIntent = manager
.getLaunchIntentForPackage(packageName);
notificationIntent.addCategory(Intent.CATEGORY_LAUNCHER);
**notificationIntent.putExtra("fromRemote", true);**
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0,
notificationIntent, 0);
NotificationManager notificationManager = (NotificationManager) context
.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification();
notification.icon = R.drawable.icon;
notification.tickerText = message;
notification.number = badge;
notification.when = System.currentTimeMillis();
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notification.defaults = Notification.DEFAULT_ALL;
notification.setLatestEventInfo(context, "Draw Something", message,
pendingIntent);
notification.contentIntent = pendingIntent;
notificationManager.notify(0, notification);
나는
notificationIntent.putExtra("fromRemote", true);
설정을 시도했지만 응용 프로그램을 시작할 때 의도에는 엑스트라가 없었다. 내 mainactivity
Bundle extras = getIntent().getExtras();
if (extras != null) {
print("onCreate - bundle has extras");
for (String key: extras.keySet())
{
Log.v ("mytag", "MainActivity onCreate key =" + key);
}
}
else {
Log.v ("mytag", "onCreate - bundle has NO extras");
}
내가 얻을 출력의에서 onCreate 함수
내 코드에서 onCreate입니다 - 번들 NO 엑스트라가 없습니다. 따라서 엑스트라가 통과하지 못합니다.
그래서 다른 방법이 있습니까 ?? iOS에서 매우 쉽습니다.
그냥 서버에 뭔가를 게시 :) – Sadegh
http://stackoverflow.com/questions/1198558/매개 변수 - 보낸 사람 - 알림 - 클릭 투 - 활동 - – Urban
감사합니다 Urban - 이것에 대한 모든 종류의 질문을 검색해 보았습니다 :) - 작동했습니다 – Anand