Android-动态修改APP桌面图标

背景

最近公司有个动态修改APP桌面图标的需求,需要做一下技术调研,网上查了一下实现方案,然后参考网上的方案写了个实现demo,在这里记录一下。

题外话:由于图标切换都是本地配置的,产品问了一句:“图标能不能支持服务端动态下发?”,我想了一下回复他:“这是不可能的,设想一下,APP提交审核时候使用的是合规图片,过审之后,动态下发的时候突然下发了一张违规图片(比如:黄赌毒),应用市场怎么监管?所以这个是不可能的。”

废话少说,先上效果图

实现

1.新建项目,实现一个MainActivity,layout布局中添加四个按钮,其中三个为切换图标按钮,最后一个为恢复默认图标按钮

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <Button
        android:id="@+id/btn1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="B1"
        android:layout_marginTop="100dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <Button
        android:id="@+id/btn2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="B2"
        android:layout_mar
评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值