Example usage for android.app ActivityManager getAppTasks

List of usage examples for android.app ActivityManager getAppTasks

Introduction

In this page you can find the example usage for android.app ActivityManager getAppTasks.

Prototype

public List<ActivityManager.AppTask> getAppTasks() 

Source Link

Document

Get the list of tasks associated with the calling application.

Usage

From source file:io.mattcarroll.hover.hoverdemo.App.java

private void setupAppStateTracking() {
    ActivityManager activityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);

    AppStateTracker.init(this, Bus.getInstance());

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        if (activityManager.getAppTasks().size() > 0) {
            AppStateTracker.getInstance().trackTask(activityManager.getAppTasks().get(0).getTaskInfo());
        }//w w  w  .jav a  2s.c  o  m
    }
}

From source file:org.chromium.chrome.browser.download.DownloadNotificationService.java

@Override
public void onTaskRemoved(Intent rootIntent) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        ActivityManager am = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
        List<ActivityManager.AppTask> tasks = am.getAppTasks();
        // In multi-window case, there could be multiple tasks. Only swiping away the last
        // activity should be pause the notification.
        if (tasks.size() > 0)
            return;
    }/*from w w w .j a v a 2  s . c  o m*/
    mStopPostingProgressNotifications = true;
    // This funcion is called when Chrome is swiped away from the recent apps
    // drawer. So it doesn't catch all scenarios that chrome can get killed.
    // This will only help Android 4.4.2.
    onBrowserKilled();
}