
苹果用户打开设置点击主屏幕选项,点击打开添加到主屏幕,在app资源库添加app图标即可。
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中用的方法,怎么自定义一看就懂了
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)