-2
期待: 我在通知欄中顯示多個通知。在這個通知中,我有三個按鈕,如1,2和3.從通知中,如果單擊1按鈕,則必須先執行第一個活動,如果單擊2按鈕,則必須執行與第3個按鈕相同的第二個活動。活動未從通知欄中打開
但我堅持如下:
1顯示多個通知=>沒有問題 2.但是,如果我點擊1個按鈕,它會在第一次活動(現在的應用程序是開放)再次當我點擊第1個按鈕一些其他通知作爲顯示在通知狀態欄它不打開所述第一活動
AirshipReceiver(推送接收器)
@Override
protected boolean onNotificationOpened(@NonNull Context context, @NonNull NotificationInfo notificationInfo, @NonNull ActionButtonInfo actionButtonInfo) {
Log.i(TAG, "Notification action button opened. Button ID: " + actionButtonInfo.getButtonId() + ". NotificationId: " + notificationInfo.getNotificationId());
Toast.makeText(context.getApplicationContext(),"Button Click",Toast.LENGTH_LONG).show();
Log.e("@@@@@@@ID", String.valueOf(notificationInfo.getNotificationId()));
Log.e("$$", String.valueOf(notificationInfo.getMessage().getAlert()));
Log.e("eGSSSHKJHSHJS", (String) notificationInfo.getMessage().getPushBundle().get("AlarmJson"));
String pushjson=(String) notificationInfo.getMessage().getPushBundle().get("AlarmJson");
***if(actionButtonInfo.getButtonId()!=null && actionButtonInfo.getButtonId().equalsIgnoreCase("Graph")) {
Log.e("Graph","You clicked Graph");
Toast.makeText(context.getApplicationContext(),"Graph Click",Toast.LENGTH_LONG).show();
Intent i = new Intent(context.getApplicationContext(), **ResultActivity**.class);
i.putExtra("From", "[email protected]@#graphicViewRoute");
i.putExtra("Pushjson","[email protected]@"+pushjson);
//i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_NEW_TASK |Intent.FLAG_ACTIVITY_CLEAR_TOP |Intent.FLAG_ACTIVITY_SINGLE_TOP);
context.startActivity(i);
return true;***
}
else if(actionButtonInfo.getButtonId()!=null && actionButtonInfo.getButtonId().equalsIgnoreCase("DD"))
{
Log.e("DD","You clicked DD");
Intent i = new Intent(context.getApplicationContext(), **ResultActivity**.class);
i.putExtra("From", "[email protected]@#ddviewRoute");
i.putExtra("Pushjson","[email protected]@"+pushjson);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
i.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
return true;
}
// Return false here to allow Urban Airship to auto launch the launcher
// activity for foreground notification action buttons
return false;
}
個
ResultActivity.class:
public class ResultActivity extends CordovaActivity{
public static boolean mIsInForegroundMode;
public static String PREF_FILE = "eG_sp";
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
Log.e("ResultActivity","You ResultActivity");
Bundle extras = getIntent().getExtras();
String pushPage = extras.getString("From");
String pushJSON = extras.getString("Pushjson");
Toast.makeText(getApplicationContext(),"ResultActivity Click",Toast.LENGTH_LONG).show();
Log.e("ResultActivity",pushPage+pushJSON);
//super.loadUrl("file:///android_asset/www/index.html");
SharedPreferences.Editor editor = getSharedPreferences(PREF_FILE, MODE_APPEND).edit();
editor.putString("pushPage", pushPage);
editor.putString("pushJSON",pushJSON);
editor.commit();
super.loadUrl("file:///android_asset/www/index.html");
}
@Override
protected void onPause(){
super.onPause();
mIsInForegroundMode = false;
}
@Override
protected void onResume() {
super.onResume();
mIsInForegroundMode=true;
}
@Override
protected void onStop() {
super.onStop();
mIsInForegroundMode=false;
}
@Override
protected void onStart() {
super.onStart();
mIsInForegroundMode=true;
}
@Override
public void onDestroy() {
LOG.d(TAG, "CordovaActivity.onDestroy()");
super.onDestroy();
mIsInForegroundMode=false;
}
}
發佈您用於創建通知的代碼。 –
@David Wasser我已更新帖子。請檢查它 –
對不起,我沒有看到任何代碼**創建**通知。發佈創建通知的代碼請 –