get Running package - Android App

Android examples for App:Package

Description

get Running package

Demo Code


//package com.java2s;

import android.app.ActivityManager;
import android.content.Context;

public class Main {

    public static String getRunningPkg(Context con) {
        ActivityManager am = (ActivityManager) con
                .getSystemService(Context.ACTIVITY_SERVICE);

        return am.getRunningTasks(1).get(0).topActivity.getPackageName();
    }/*from ww  w  . j a v  a  2  s.  com*/
}

Related Tutorials