方法一:
adb shell "dumpsys window | grep mCurrentFocus

方法二:

android.app.ActivityManager am =  (android.app.ActivityManager) getApplicationContext().getSystemService(ACTIVITY_SERVICE);
android.content.ComponentName cn = am.getRunningTasks(1).get(0).topActivity;
//获取当前Activity名:
cn.getClassName()
//获取当前包名:
cn.getPackageName()