«

Android获取系统启动器、电话、短信和相机包名

时间:2024-3-2 18:23     作者:韩俊     分类: Android


                private ResolveInfo res;
                private Intent infoIntent;
                //获取启动器包名
                infoIntent = new Intent(Intent.ACTION_MAIN);
                infoIntent.addCategory(Intent.CATEGORY_HOME);
                res = getPackageManager().resolveActivity(infoIntent, 0);
                if (res != null) {                        
                        Log.e("LauncherName", res.activityInfo.packageName);
                }
                //获取电话包名
                infoIntent = new Intent(Intent.ACTION_DIAL);
                res = getPackageManager().resolveActivity(infoIntent, 0);
                if (res != null) {
                        Log.e("ACTION_CALL", res.activityInfo.packageName);
                }
                //获取短信包名
                Uri uri = Uri.parse("smsto:10086");  
                infoIntent = new Intent(Intent.ACTION_SENDTO, uri);
                res = getPackageManager().resolveActivity(infoIntent, 0);
                if (res != null) {
                        Log.e("ACTION_SEND", res.activityInfo.packageName);
                }
                //获取相机包名
                infoIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                res = getPackageManager().resolveActivity(infoIntent, 0);
                if (res != null) {
                        Log.e("ACTION_IMAGE_CAPTURE", res.activityInfo.packageName);
                }

标签: android

热门推荐