2013-03-25 3 views
0

Мне нужно отправить параметры, когда пользователь нажимает на уведомление.параметры передачи из ожидающего намерения

Мой код для создания Извещение:

 NotificationManager notifManager = (NotificationManager) c.getSystemService(c.NOTIFICATION_SERVICE); 
     Notification note = new Notification(R.drawable.ic_launcher, "Smartdrifter", System.currentTimeMillis()); 

     Intent WA = new Intent(c, WebActivity.class); 

     WA.putExtra("url", urlTarget); 
     WA.putExtra("valid", notifId); 
     WA.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
     PendingIntent intent = PendingIntent.getActivity(c, 0, WA, 0); 

     notifManager.cancel(notifId); 
     note.setLatestEventInfo(c, titulo, texto, teste()); 

     notifManager.notify(notifId, note); 

Мой код для запроса Params:

String url = getIntent().getStringExtra("url"); 

Но ответ NULL.

Существует другая форма параметров запроса?

Спасибо.

+0

Что такое 'urlTarget'? – RobinHood

+0

Извините! urlTarget является строкой, а notifId длинной – JARPSimoes

ответ

2

Используйте встроенный метод: onNewIntent(Intent intent) в вашей деятельности WebActivity, чтобы поймать ожидающее намерения.

@Override 
public void onNewIntent(Intent intent) { 

    setIntent(intent); 
    String url = getIntent().getStringExtra("url"); 

} 
Смежные вопросы