【发布时间】:2013-05-24 18:50:49
【问题描述】:
我正在开发一个基于 phonegap 的 Android 应用程序,并且我正在编写代码来处理通知。这是应该引发通知的一段代码的 sn-p:
Intent notificationIntent = new Intent(context, MainActivity.class);
// set intent so it does not start a new activity
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP |
Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent intent =
PendingIntent.getActivity(context, 0, notificationIntent, 0);
notification.setLatestEventInfo(context, title, message, intent);
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notificationManager.notify(0, notification);
我想准备 Intent,以便它在与通知内容相关的页面中打开应用程序。到目前为止,我发现的唯一与此相关的是以下行,位于MainActivity 类(扩展DroidGap 类)中的onCreate 方法中:
super.loadUrl("file:///android_asset/www/index.html", 10000);
但我想从上面的代码中动态设置该 URL,或者,在最坏的(或最好的,我真的不知道......)的情况下,将其参数化并将参数从上面的代码传递给 onCreate 方法。我怎么做?提前谢谢...
【问题讨论】: