如何在主屏幕添加app图标

如何在主屏幕添加app图标,第1张

苹果用户打开设置点击主屏幕选项,点击打开添加到主屏幕,在app资源库添加app图标即可。

1、首先在苹果手机中进入设置,点击【主屏幕】选项。

2、找到【添加到主屏幕】设置。

3、接着点击勾选【添加到主屏幕】选项。

4、最后在APP资源库中长按图标进行添加,就完成了。

void addShortcutToDesktop(){

Intent shortcut = new Intent(ACTION_INSTALL)

BitmapDrawable iconBitmapDrawabel = null

// 获取应用基本信息

String label = this.getPackageName()

PackageManager packageManager = getPackageManager()

try {

iconBitmapDrawabel = (BitmapDrawable) packageManager.getApplicationIcon(label)

} catch (NameNotFoundException e) {

e.printStackTrace()

}

// 设置属性

shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME, label)

shortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON, iconBitmapDrawabel.getBitmap())

// 是否允许重复创建 -- fase-->否

shortcut.putExtra("duplicate", false)

// 设置启动程序

ComponentName comp = new ComponentName(label,"." + this.getLocalClassName())

shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, new Intent(Intent.ACTION_MAIN).setComponent(comp))

sendBroadcast(shortcut)

}

android支持发送Intent.EXTRA_SHORTCUT_ICON_RESOURCE的方式添加图标,这个是在activity中用的方法,怎么自定义一看就懂了


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/bake/11381683.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-15
下一篇2023-05-15

发表评论

登录后才能评论

评论列表(0条)

    保存