欢迎访问 生活随笔!

生活随笔

当前位置: 首页 >

android 桌面图标创建,android创建桌面图标

发布时间:2025/3/19 52 豆豆
生活随笔 收集整理的这篇文章主要介绍了 android 桌面图标创建,android创建桌面图标 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

private void setDeskShortCut() {

boolean installedshortcut = sp.getBoolean("installedshortcut", false);

if (installedshortcut) {

return;

}

//创建一个快捷方式的意图

Intent intent = new Intent(

"com.android.launcher.action.INSTALL_SHORTCUT");

intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, //快捷方式的名称

getString(R.string.app_name));

intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, BitmapFactory

.decodeResource(getResources(), R.drawable.mobilesafe_logo_s)); //快捷方式的图标

//设置点击这个快捷方式,打开哪个activity

Intent openMS = new Intent("com.hy.test.activities.home");

openMS.addCategory("android.intent.category.DEFAULT");

intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, openMS); //快捷方式的打开界面

sendBroadcast(intent); //发送一个广播

Editor editor = sp.edit();

editor.putBoolean("installedshortcut", true);

editor.commit();

}

!!!添加权限:com.android.launcher.permission.INSTALL_SHORTCUT

总结

以上是生活随笔为你收集整理的android 桌面图标创建,android创建桌面图标的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。