我试图创建应用程序快捷方式,我指的是一些文件和我使用Android的安装快捷方式,但快捷方式图标不显示
Intent intent = new Intent("com.android.launcher.action.INSTALL_SHORTCUT");
launchIntent.setAction(Intent.ACTION_MAIN);
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, new Intent(getApplication(), MainActivity.class));
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "test app");
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(getApplicationContext(),R.mipmap.ic_launcher));
getApplicationContext().sendBroadcast(intent);
我也允许添加到我的清单
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
但是,它可以在我的旧HTC手机(android 4.4)上正常工作,但不会在另一部手机上使用三星s6(android7.0)。
任何人都可以帮助我吗?谢谢!
这是你自己的应用程序?是否有一个原因,你没有从AndroidManifest做到这一点? –