如何在通知单击时重新加载 phonegap 索引.html文件



我用Phonegap和Java做了一个安卓应用程序。我在应用程序中成功收到通知,单击通知应用程序后从后台启动。我想在单击通知后重新加载我的 Index.html 文件。我该如何处理这个问题?请帮忙提前谢谢。

谢谢 mit,这是我的生成通知代码

private static void generateNotification(Context context, String message) {
    int icon = R.drawable.ic_launcher;
    long when = System.currentTimeMillis();
    NotificationManager notificationManager = (NotificationManager)
  context.getSystemService(Context.NOTIFICATION_SERVICE);
    Notification notification = new Notification(icon, message, when);
    String title = context.getString(R.string.app_name);
    Intent notificationIntent = new Intent(context, MainActivity.class);
    notificationIntent.putExtra("data1", "data1");
    MainActivity ObjMain=new MainActivity();
    ObjMain.sendJavascript("TestFunc");
    // set intent so it does not start a new activity
    notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP |
            Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
    PendingIntent intent =
            PendingIntent.getActivity(context, 0, notificationIntent, 0);
    PendingIntent contentIntent =PendingIntent.getActivity(context, 0, new Intent(context, MainActivity.class), 0);
    notification.setLatestEventInfo(context, title, message, intent);
    notification.flags |= Notification.FLAG_AUTO_CANCEL;
    // Play default notification sound
    notification.defaults |= Notification.DEFAULT_SOUND;
    //notification.sound = Uri.parse("android.resource://" + context.getPackageName() + "your_sound_file_name.mp3");
    // Vibrate if vibrate is enabled
    notification.defaults |= Notification.DEFAULT_VIBRATE;
    if (message!="")
    {        
        notificationManager.notify(0, notification);
    }
}

最新更新