Android 从挂起的意图传递参数
我需要在用户单击通知时发送参数 我的创建通知代码:Android 从挂起的意图传递参数,android,notifications,android-pendingintent,Android,Notifications,Android Pendingintent,我需要在用户单击通知时发送参数 我的创建通知代码: NotificationManager notifManager = (NotificationManager) c.getSystemService(c.NOTIFICATION_SERVICE); Notification note = new Notification(R.drawable.ic_launcher, "Smartdrifter", System.currentTimeMillis());
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);
我的请求参数代码:
String url = getIntent().getStringExtra("url");
但响应是空的
还有另一种形式的请求参数吗
谢谢。在活动
WebActivity
中使用内置方法:onNewIntent(Intent-Intent)
,以捕获挂起的意图
@Override
public void onNewIntent(Intent intent) {
setIntent(intent);
String url = getIntent().getStringExtra("url");
}
很抱歉urlTarget是一个字符串,notifId为长字符串