我必须在从java插件中创建的警报中单击“确定”时调用javascript方法。实际上,当点击状态栏中的通知时会显示警报。
//从通知单上的待处理意图中收集信息的方法点击
public void launchNotification()
{
Intent intent = getIntent();
if(intent!=null)
{
if(intent.getExtras().getBoolean("fromNotification"))
{
final String notificationType = intent.getStringExtra("notificationType");
final String twoWeeksNotificationType = intent.getStringExtra("2WeeksNotificationType");
final String tasksNotificationType = intent.getStringExtra("tasksNotificationType");
if(notificationType != null || twoWeeksNotificationType != null || tasksNotificationType != null)
{
if(notificationType != null && notificationType.equals("dailyReviewAvailable"))
{
NotificationManager nMgr = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);
nMgr.cancel("DailyReview", 0);
Handler handler = new Handler();
handler.postDelayed(
new Runnable() {
public void run() {
showAlertForNotifications(notificationType);
}
}, 1000L);
}
intent.putExtra("fromNotification",false);
}
else
finish();
}
}
//点击通知后启动提醒的方法无效
showAlertForNotifications(String notificationIdStr) {
if(notificationIdStr.equals("dailyReviewAvailable")) {
Log.d("Notification", "Daily Review Start");
AlertDialog.Builder adb = new AlertDialog.Builder(this);
adb.setTitle("Actions Hero");
adb.setMessage("Would you like to send your daily review?");
adb.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id)
{
showDailyReview();
}
});
adb.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id)
{
// Action for 'Cancel' Button
dialog.cancel();
finish();
}
});
//adb.setIcon(R.drawable.icon);
adb.show();
}
else {
//do later
}
}
//在java上单击警报按钮
中调用javascript函数的方法 public void showDailyReview() {
Log.v("showDailyReview", "Before");
// This javascript function cannot be invoked super.sendJavascript("javascript:app.runningDailyReview('DailyReview')");
Log.v("showDailyReview", "After");
finish();
}
如何在显示的警告上点击确定时调用javascript方法? 感谢..