get Running Pkg - Android android.content.pm

Android examples for android.content.pm:PackageManager

Description

get Running Pkg

Demo Code

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();
  }// ww w. j  a v a  2  s .c  o  m

}

Related Tutorials