期待: 我在通知栏中显示多个通知。在这个通知中,我有三个按钮,如1,2和3.从通知中点击1按钮然后它必须去第一个活动,如果点击2按钮它必须第二个活动相同,如3按钮也。
但我被困在下面:
1。显示多个通知=&gt;没问题 2.但是,如果我单击第一个按钮,它将进行第一个活动。(现在应用程序正在打开)当我单击第一个按钮时,通知状态栏中显示的其他通知不会打开第一个活动 < / p>
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", "from@@#graphicViewRoute");
i.putExtra("Pushjson","json@@"+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", "from@@#ddviewRoute");
i.putExtra("Pushjson","json@@"+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;
}
}
答案 0 :(得分:0)
我有如下的setFloags。现在它正在运作。
i.setFlags (Intent.FLAG_ACTIVITY_CLEAR_TASK| Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK | Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);