2013-10-28 5 views
0

사용자가 알림에서 알림을 클릭하면 다른 활동으로 리디렉션 할 수 있습니까?android에서 알림을 캡처

예를

위해 나는 Google 캘린더의 일정을 만들고 사용자가 클릭 할 때 통지가있을 때, 내 활동을 열보다는 Google 캘린더에 직접 갈 것입니다. 이 도움이

private void generateNotification(Context context, String message, 
long when, String query) { 
int icon = R.drawable.icon; 
long when = System.currentTimeMillis(); 
String appname = context.getResources().getString(R.string.app_name); 
NotificationManager notificationManager = (NotificationManager) context 
    .getSystemService(Context.NOTIFICATION_SERVICE); 
int currentapiVersion = android.os.Build.VERSION.SDK_INT; 
Notification notification; 

Intent intent = new Intent(context, MainActivity.class); 
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, 
    intent, 0); 

if (currentapiVersion < android.os.Build.VERSION_CODES.HONEYCOMB) { 
    notification = new Notification(icon, message, when); 
    notification.setLatestEventInfo(context, appname, message, 
      contentIntent); 
    notification.flags = Notification.FLAG_AUTO_CANCEL; 
    notificationManager.notify((int) when, notification); 

} else { 
    NotificationCompat.Builder builder = new NotificationCompat.Builder(
      context); 
    notification = builder.setContentIntent(contentIntent) 
      .setSmallIcon(icon).setTicker(appname).setWhen(when) 
      .setAutoCancel(true).setContentTitle(appname) 
      .setContentText(message).build(); 

    notificationManager.notify((int) when, notification); 

} 

희망 :

+0

[this] (http://stackoverflow.com/a/13716784/896038)을 보시면 필요한 것이 맞을 것 같습니다. –

답변

0

이보십시오.

관련 문제