Java Code Examples for android.content.Intent#FLAG_ACTIVITY_SINGLE_TOP
The following examples show how to use
android.content.Intent#FLAG_ACTIVITY_SINGLE_TOP .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CallNotificationManager.java From react-native-twilio-programmable-voice with MIT License | 5 votes |
public Intent getLaunchIntent(ReactApplicationContext context, int notificationId, CallInvite callInvite, Boolean shouldStartNewTask, int appImportance ) { Intent launchIntent = new Intent(context, getMainActivityClass(context)); int launchFlag = Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP; if (shouldStartNewTask || appImportance != ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND) { launchFlag = Intent.FLAG_ACTIVITY_NEW_TASK; } launchIntent.setAction(ACTION_INCOMING_CALL) .putExtra(INCOMING_CALL_NOTIFICATION_ID, notificationId) .addFlags( launchFlag + WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED + WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD + WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON + WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON ); if (callInvite != null) { launchIntent.putExtra(INCOMING_CALL_INVITE, callInvite); } return launchIntent; }
Example 2
Source File: TaskRecord.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
/** * Perform clear operation as requested by * {@link Intent#FLAG_ACTIVITY_CLEAR_TOP}: search from the top of the * stack to the given task, then look for * an instance of that activity in the stack and, if found, finish all * activities on top of it and return the instance. * * @param newR Description of the new activity being started. * @return Returns the old activity that should be continued to be used, * or null if none was found. */ final ActivityRecord performClearTaskLocked(ActivityRecord newR, int launchFlags) { int numActivities = mActivities.size(); for (int activityNdx = numActivities - 1; activityNdx >= 0; --activityNdx) { ActivityRecord r = mActivities.get(activityNdx); if (r.finishing) { continue; } if (r.realActivity.equals(newR.realActivity)) { // Here it is! Now finish everything in front... final ActivityRecord ret = r; for (++activityNdx; activityNdx < numActivities; ++activityNdx) { r = mActivities.get(activityNdx); if (r.finishing) { continue; } ActivityOptions opts = r.takeOptionsLocked(); if (opts != null) { ret.updateOptionsLocked(opts); } if (mStack != null && mStack.finishActivityLocked( r, Activity.RESULT_CANCELED, null, "clear-task-stack", false)) { --activityNdx; --numActivities; } } // Finally, if this is a normal launch mode (that is, not // expecting onNewIntent()), then we will finish the current // instance of the activity so a new fresh one can be started. if (ret.launchMode == ActivityInfo.LAUNCH_MULTIPLE && (launchFlags & Intent.FLAG_ACTIVITY_SINGLE_TOP) == 0 && !ActivityStarter.isDocumentLaunchesIntoExisting(launchFlags)) { if (!ret.finishing) { if (mStack != null) { mStack.finishActivityLocked( ret, Activity.RESULT_CANCELED, null, "clear-task-top", false); } return null; } } return ret; } } return null; }
Example 3
Source File: IntentUtils.java From Phantom with Apache License 2.0 | 4 votes |
@NonNull public static Intent wrapToActivityHostProxyIntentIfNeeded(Intent intent) { if (intent.hasExtra(Constants.ORIGIN_INTENT)) { VLog.v("skip ActivityHostProxy intent: %s", intent); // 已经是代理 Intent 了 return intent; } // Activity 是否在插件中 ? final String packageName = ACTIVITY_INTENT_RESOLVER.resolveIntentTarget(intent); VLog.v("intent: %s, resolveIntentTarget: %s", intent, packageName); if (packageName == null) { // Activity 在宿主或其他应用,忽略掉 VLog.v("skip intent not in plugin: %s", intent); return intent; } // Activity 在插件中, 返回代理 Activity Intent newIntent = new Intent(intent); if (null != newIntent.getExtras()) { //清空extras newIntent.replaceExtras(new Bundle()); } final ComponentName oldComponent = intent.getComponent(); final String oldClassName = oldComponent.getClassName(); final ComponentName newComponent = new ComponentName(packageName, oldClassName); VLog.d("old: %s, new: %s", oldComponent, newComponent); ActivityInfo ai = PhantomCore.getInstance() .findActivityInfo(new ComponentName(packageName, oldClassName)); int launchMode = ai.launchMode; if ((intent.getFlags() & Intent.FLAG_ACTIVITY_SINGLE_TOP) != 0) { launchMode = ActivityInfo.LAUNCH_SINGLE_TOP; } try { String proxyClass = LaunchModeManager.getInstance() .resolveActivity(packageName + "/" + oldClassName, launchMode); newIntent.setComponent(new ComponentName(PhantomCore.getInstance().getContext(), proxyClass)); newIntent.putExtra(Constants.ORIGIN_INTENT, intent.setComponent(newComponent)); return newIntent; } catch (LaunchModeManager.ProxyActivityLessException e) { VLog.w(e, "no available activity for intent: %s, launch mode: %d", intent, launchMode); // TODO: dump proxy activity pool return intent; } }
Example 4
Source File: ActivityRouter.java From Meepo with Apache License 2.0 | 4 votes |
@Clazz(BActivity.class) @Flags(Intent.FLAG_ACTIVITY_SINGLE_TOP) void gotoB( @NonNull Context context, @BundleParam(ARG_TITLE) @NonNull String title );