You can get current name package using
ActivityManager am = (ActivityManager) mContext
.getSystemService(Activity.ACTIVITY_SERVICE);
String packageName = am.getRunningTasks(1).get(0).topActivity
.getPackageName();
You can use this package name to get current active application
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…