Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/200.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何以编程方式设置默认主应用程序_Android_Android Launcher - Fatal编程技术网

Android 如何以编程方式设置默认主应用程序

Android 如何以编程方式设置默认主应用程序,android,android-launcher,Android,Android Launcher,我想让我的android应用程序设置一个home应用程序(单击home按钮时的默认启动程序应用程序)。我已经在清单文件中设置了intent过滤器 <intent-filter> <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAU

我想让我的android应用程序设置一个home应用程序(单击home按钮时的默认启动程序应用程序)。我已经在清单文件中设置了
intent过滤器

           <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
                <category android:name="android.intent.category.HOME"/>
                <category android:name="android.intent.category.DEFAULT"/>
            </intent-filter>

步骤1:您需要拥有设备的root访问权限才能安装默认启动器

步骤2:卸载默认启动器
adb卸载app.package

然后转到您想要的主屏幕应用程序。然后转到“设置”并将其设置为默认值

注意:只能使用根设备

如果要使用adb命令执行此操作

首先,您需要删除默认启动器,然后需要在系统应用程序中移动launchera.apk。。。。进去 系统->媒体->默认->您需要在此处放置apk。。。 每个固件的路径可能不同


我已经有根访问权限了。我知道如何手动执行此操作,或启动“主页设置”活动,显示如何选择我的应用程序作为主页应用程序。我在问题中写的是,我想通过编程或ADB命令来实现这一点。这是目前仅通过清单实现的
07-30 16:56:16.809 1289-2215/? I/PackageManager: Replacing preferred activity com.myapp.hp/.MainActivity for user 0:
07-30 16:56:16.809 1289-2215/? I/PackageManager:   Action: "android.intent.action.MAIN"
07-30 16:56:16.809 1289-2215/? I/PackageManager:   Category: "android.intent.category.HOME"
07-30 16:56:16.809 1289-2215/? I/PackageManager:   Category: "android.intent.category.DEFAULT"
07-30 16:56:16.809 1289-2215/? I/PackageManager:   AutoVerify=false