android 获取HOME组件的Activity信息

Android Activity里如何获取当前桌面是什么包什么类

上code:

    protected void handleClick() {
        Intent intent = new Intent();
        intent.setAction(Intent.ACTION_MAIN);
        intent.addCategory(Intent.CATEGORY_HOME);
        ResolveInfo info = this.getPackageManager().resolveActivity(intent,0);
        Log.d(TAG,"packageName="+info.activityInfo.packageName);
        Log.d(TAG,"getClass="+info.activityInfo.getClass());
        Log.d(TAG,"processName="+info.activityInfo.processName);
        Log.d(TAG,"name="+info.activityInfo.name);

    }


$ adb logcat 

AsTest_NoUiTest: packageName=com.asus.launcher3
AsTest_NoUiTest: getClass=class android.content.pm.ActivityInfo
AsTest_NoUiTest: processName=com.asus.launcher3
AsTest_NoUiTest: name=com.asus.launcher3.Launcher


得到ResolveInfo,
ResolveInfo.activityInfo.packageName
ResolveInfo.activityInfo.name
得到桌面的包名类名。



你可能感兴趣的:(Android)