jjzjj

activePackages

全部标签

android - 如何在android 5.0(L)中获取正在运行的应用程序 Activity 名称?

我正在使用以下代码获取android中当前正在运行的Activity名称。ActivityManageram=(ActivityManager)aContext.getSystemService(Context.ACTIVITY_SERVICE);Listalltasks=am.getRunningTasks(1);ComponentNamecomponentInfo=alltasks.get(0).topActivity;componentInfo.getClassName();System.out.println("Current:"+componentInfo.getClassN