Example usage for android.app ActivityManager getRecentTasks

List of usage examples for android.app ActivityManager getRecentTasks

Introduction

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

Prototype

@Deprecated
public List<RecentTaskInfo> getRecentTasks(int maxNum, int flags) throws SecurityException 

Source Link

Document

Return a list of the tasks that the user has recently launched, with the most recent being first and older ones after in order.

Usage

From source file:mobisocial.musubi.ui.FeedIdentityGrid.java

String getCallerAppId() {
    ActivityManager manager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
    List<RecentTaskInfo> infos = manager.getRecentTasks(1, 0);
    if (infos.size() == 0) {
        Log.w(TAG, "couldn't get info");
        return null;
    }/*from w w  w  . ja  v  a  2 s  . com*/

    Intent base = infos.get(0).baseIntent;
    return base.getComponent().getPackageName();
}