Java Code Examples for android.app.Activity#getTaskId()
The following examples show how to use
android.app.Activity#getTaskId() .
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: IncognitoNotificationService.java From delion with Apache License 2.0 | 6 votes |
private void focusChromeIfNecessary() { Set<Integer> visibleTaskIds = getTaskIdsForVisibleActivities(); int tabbedTaskId = -1; List<WeakReference<Activity>> runningActivities = ApplicationStatus.getRunningActivities(); for (int i = 0; i < runningActivities.size(); i++) { Activity activity = runningActivities.get(i).get(); if (activity == null) continue; if (activity instanceof ChromeTabbedActivity) { tabbedTaskId = activity.getTaskId(); break; } } // If the task containing the tabbed activity is visible, then do nothing as there is no // snapshot that would need to be regenerated. if (visibleTaskIds.contains(tabbedTaskId)) return; Context context = ContextUtils.getApplicationContext(); Intent startIntent = new Intent(Intent.ACTION_MAIN); startIntent.setPackage(context.getPackageName()); startIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(startIntent); }
Example 2
Source File: IncognitoNotificationService.java From AndroidChromium with Apache License 2.0 | 6 votes |
private void focusChromeIfNecessary() { Set<Integer> visibleTaskIds = getTaskIdsForVisibleActivities(); int tabbedTaskId = -1; List<WeakReference<Activity>> runningActivities = ApplicationStatus.getRunningActivities(); for (int i = 0; i < runningActivities.size(); i++) { Activity activity = runningActivities.get(i).get(); if (activity == null) continue; if (activity instanceof ChromeTabbedActivity) { tabbedTaskId = activity.getTaskId(); break; } } // If the task containing the tabbed activity is visible, then do nothing as there is no // snapshot that would need to be regenerated. if (visibleTaskIds.contains(tabbedTaskId)) return; Context context = ContextUtils.getApplicationContext(); Intent startIntent = new Intent(Intent.ACTION_MAIN); startIntent.setPackage(context.getPackageName()); startIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(startIntent); }
Example 3
Source File: ActivityArchitector.java From Mortar-architect with MIT License | 6 votes |
public static MortarScope onCreateScope(Activity activity, Bundle savedInstanceState, Architected architected) { String scopeName = activity.getLocalClassName() + "-task-" + activity.getTaskId(); MortarScope scope = MortarScope.findChild(activity.getApplicationContext(), scopeName); if (scope == null) { MortarScope parentScope = MortarScope.getScope(activity.getApplicationContext()); MortarScope.Builder builder = parentScope.buildChild() .withService(BundleServiceRunner.SERVICE_NAME, new BundleServiceRunner()); architected.configureScope(builder, parentScope); scope = builder.build(scopeName); architected.createNavigator(scope); } BundleServiceRunner.getBundleServiceRunner(scope).onCreate(savedInstanceState); return scope; }
Example 4
Source File: ShareActivity.java From 365browser with Apache License 2.0 | 6 votes |
/** * Returns the ChromeActivity that called the share intent picker. */ private ChromeActivity getTriggeringActivity() { int triggeringTaskId = IntentUtils.safeGetIntExtra(getIntent(), ShareHelper.EXTRA_TASK_ID, 0); List<WeakReference<Activity>> activities = ApplicationStatus.getRunningActivities(); ChromeActivity triggeringActivity = null; for (int i = 0; i < activities.size(); i++) { Activity activity = activities.get(i).get(); if (activity == null) continue; if (activity.getTaskId() == triggeringTaskId && activity instanceof ChromeActivity) { return (ChromeActivity) activity; } } return null; }
Example 5
Source File: IncognitoNotificationService.java From 365browser with Apache License 2.0 | 6 votes |
private void focusChromeIfNecessary() { Set<Integer> visibleTaskIds = getTaskIdsForVisibleActivities(); int tabbedTaskId = -1; List<WeakReference<Activity>> runningActivities = ApplicationStatus.getRunningActivities(); for (int i = 0; i < runningActivities.size(); i++) { Activity activity = runningActivities.get(i).get(); if (activity == null) continue; if (activity instanceof ChromeTabbedActivity) { tabbedTaskId = activity.getTaskId(); break; } } // If the task containing the tabbed activity is visible, then do nothing as there is no // snapshot that would need to be regenerated. if (visibleTaskIds.contains(tabbedTaskId)) return; Context context = ContextUtils.getApplicationContext(); Intent startIntent = new Intent(Intent.ACTION_MAIN); startIntent.setPackage(context.getPackageName()); startIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(startIntent); }
Example 6
Source File: ActivityManager.java From freeline with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void onActivityCreated(Activity activity, Bundle savedInstanceState) { sActivitiesRefs.put(activity, ACTIVITY_CREATED); if (sFirstTaskId == 0L) { sFirstTaskId = activity.getTaskId(); } }