我一直在处理订购出租车的申请。 在驱动程序的应用程序中,我有一个推送服务实例2活动,具体取决于推送内容。如果来自客户的呼叫启动活动1,如果已选择确认以获取乘客启动活动2.除了活动2能够启动呼叫电话或活动三按下各种按钮,但每次她抛出电话或活动3返回时返回活动1
My Manifest看起来像:
<activity
android:label="@string/app_name"
android:name=".MainActivity"
android:screenOrientation="portrait"
android:launchMode="singleTop"
android:alwaysRetainTaskState="true"
android:configChanges="orientation|keyboardHidden|screenSize">
</activity>
<activity
android:label="@string/app_name"
android:name=".RouteActivity"
android:screenOrientation="portrait"
android:alwaysRetainTaskState="true"
android:configChanges="orientation|keyboardHidden|screenSize">
</activity>
我的推送服务;
NotificationManager mNotificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle("MyTaxi")
.setContentText(msg)
.setUsesChronometer(true);
if(GlobalPersist.getGlobalPersist("tipoPush").equals("nueva")&& GlobalPersist.getGlobalPersist("carreraencurso").equals("false"))
{
Intent notIntent = new Intent(this, MainActivity.class);
MainActivity.from=1;
notIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
this.startActivity(notIntent);
}
else if(GlobalPersist.getGlobalPersist("tipoPush").equals("cancelacion"))
{ GlobalPersist.getGlobalPersist("carreraencurso").equals("false");
Intent notIntent = new Intent(this, MainActivity.class);
MainActivity.from=1;
MainActivity.carreras.clear();
notIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_CLEAR_TOP);
this.startActivity(notIntent);
}
else
{
Intent notIntent = new Intent(this, RouteActivity.class);
//MainActivity.from=1;
MainActivity.timer.cancel();
MainActivity.isTimerActivo=false;
notIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|
Intent.FLAG_ACTIVITY_SINGLE_TOP);
this.startActivity(notIntent);
}
答案 0 :(得分:0)
致电startActivity()
后,只需致电finish()
。这会终止您的活动并允许您管理导航。