如何以编程方式创建的Andr​​oid另一个应用程序的快捷方式?快捷方式、应用程序、方式、oid

由网友(顾北清歌寒)分享简介:假设,我有一些Android应用程序,它可以帮助用户安装一些其他应用程序。有什么办法创造主屏幕上的应用程序这一个捷径?我还可以指定这些快捷键的位置?Suppose, I have some Android app which helps users to install some other apps. Is the...

假设,我有一些Android应用程序,它可以帮助用户安装一些其他应用程序。有什么办法创造主屏幕上的应用程序这一个捷径?我还可以指定这些快捷键的位置?

Suppose, I have some Android app which helps users to install some other apps. Is there any way to create a shortcut of this apps on home screen? Can I also specify the position of these shortcuts?

推荐答案

试试这个:

public void createShortCut{
    Intent shortcutintent = new Intent("com.android.launcher.action.INSTALL_SHORTCUT");
    shortcutintent.putExtra("duplicate", false);
    shortcutintent.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.shortcutname));
    Parcelable icon = Intent.ShortcutIconResource.fromContext(getApplicationContext, R.drawable.icon);
    shortcutintent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon);
    shortcutintent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, new Intent("com.whatsapp"));
    sendBroadcast(shortcutintent);
}
阅读全文

相关推荐

最新文章