Android 应用(4)——将APP设置为主界面Launcher

1、给APP设置HOME属性

将自己开发的APP设置为主界面Launcher,需要添加如下属性:

<category android:name="android.intent.category.HOME" />

e.g.

<application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
                <category android:name="android.intent.category.HOME" />
            </intent-filter>
        </activity>

2、给APP设置system属性

设置app system的属性:

android:sharedUserId="android.uid.system"

e.g.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.forlinx.android.audostart"
    android:sharedUserId="android.uid.system">
    <!---->

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">

3、给APP签名

为了设置system属性,就需要对app进行签名:
在这里插入图片描述
app设置system属性和进行签名,涉及到了Android的安全策略部分,可以参考如下链接进行了解:

https://blog.csdn.net/scottmvp/article/details/115871037
https://blog.csdn.net/scottmvp/article/details/121602149

编译app并安装到开发板,重新启动开发板,在进入桌面的阶段,会让我们选择要启动的Launcher:默认的Launcher3和我们添加的Launcher。

2、去掉原有的Launcher3

Android10.0默认的主界面程序是谷歌开发的Launcher3,现在有了关闭主界面程序的需求。我们的思路比较简单:去掉Launcher3编译生成的apk。
禁掉Launcher3源码的编译,在源码中去掉Launcher3的编译文件:

mv packages/apps/Launcher3/Android.mk packages/apps/Launcher3/Android.mk.txt
mv packages/apps/Launcher3/SecondaryDisplayLauncher/Android.mk packages/apps/Launcher3/SecondaryDisplayLauncher/Android.mk.txt

删除Launcher3的历史编译结果:

find ./out/ -name "Launcher3*" | xargs rm -rf

重新编译测试,Launcher3主界面程序已经不再启动。

  • 1
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值