我已分离从服务启动的活动,用于在某些事件后收集结果。
问题是启动了分离的活动,并且在使用
关闭用户的结果选择之后public void closeApp() {
Toast.makeText(getApplicationContext(), "Saved",Toast.LENGTH_LONG).show();
this.finish();
}
分开的活动已关闭,但"""此活动已经启动应用程序的主要活动,这不是我想要的。
我只想做以下事情:
无需启动主应用活动(如果用户想要查看收集的结果,则必须点按应用图标)。
这是我试过的:
清单:
主要活动:
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/app_name" android:launchMode="singleTop" android:name="CallPlanner" android:theme="@android:style/Theme.Black.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
分开的活动:
<activity android:name="com.result.plugin.ReceiverActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar" />
使用这些标签从服务中查看Separetd活动:
intentOne.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intentOne.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
我如何解决它,以及最佳方法是什么?
非常感谢您的帮助。
编辑:从接收方呼叫增加的活动
/*
* CALL RESULT ACTIVITY IN CASE THAT OUTGOING CALL IS ENDED, NUMBER IS AVAILABLE AND APP IS ACTIVE
*/
if (DataHolder.getAction().equals("OUTGOING_CALL")
&& !DataHolder.getPhoneNumber().isEmpty()
&& extraState.equals(TelephonyManager.EXTRA_STATE_IDLE)
&& isAppActive == 1) {
Log.i("Catched", "Catched");
Toast.makeText(context, "Catched",Toast.LENGTH_LONG).show();
// START ACTIVITY AND PASS PARAMS
intentOne = new Intent(context.getApplicationContext(),
ReceiverActivity.class);
// intentOne = new Intent(context.getApplicationContext(),
// CordovaReceiverActivity.class);
if(intentOne == null) {
throw new NullPointerException(
" :: intentOne 'param' was null inside method 'onReceive'.");
}
intentOne.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intentOne.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
//intentOne.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
//intentOne.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
//intentOne.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
/*
intentOne.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
intentOne.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
intentOne.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
intentOne.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
intentOne.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
*/
// PASS PARAM TO CALLED ACTIVITY
Bundle b = new Bundle();
b.putString("phone_number", DataHolder.getPhoneNumber());
// Put your id to your next Intent
intentOne.putExtras(b);
// START ACTIVITY
context.startActivity(intentOne);
};