私はインターネット上で見つけたすべてのソリューションを試しましたが、誰も働かなかったと思いますが、強制終了はしませんがデスクトップには何も表示されません。私は何をしないのですデスクトップ上の任意のアプリケーションのショートカットを作成する
<permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>
:
public Intent getIntentShortcut()
{
Intent i = new Intent();
i.setClassName(packageName, name);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
return i;
}
マニフェストで:
private void createShortcutOnDesktop(Application app) {
Intent shortcutIntent = new Intent();
shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, app.getIntentShortcut());
shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, app.getName());
shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(context, R.drawable.home_button));
shortcutIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
this.sendBroadcast(shortcutIntent);
finish();
}
app.getIntentShortcut()がこれです:さて、私はこれをしましたか?ありがとう。
参考のために、あなたの質問を編集すると、それをつり上げるために十分です再びフロントページに移動します。 –
完全なソースコードを提供してください。 – Nirav