-1
私はショートカット名としてユーザー入力を持つ同じアプリケーションの複数のショートカットを作成するアプリケーションを作成しようとしています。しかし、すべてのショートカットは、異なる指定されたものを行うでしょう。これのために私はショートカットname.any可能な方法を知る必要がありますか?アンドロイドのショートカットの名前を取得する
私はショートカット名としてユーザー入力を持つ同じアプリケーションの複数のショートカットを作成するアプリケーションを作成しようとしています。しかし、すべてのショートカットは、異なる指定されたものを行うでしょう。これのために私はショートカットname.any可能な方法を知る必要がありますか?アンドロイドのショートカットの名前を取得する
まず、あなたは以下のコードを使用して、ランチャーにショートカットを追加し、あなたのアプリからカスタムアクティビティを開きます変更
EditText UserInput = (EditText)findViewById(R.id.userinput_text);
final String UserString = UserInput.getText().toString();
//Gets user input^
public void createIcon(){
Intent shortcutintent = new Intent("com.android.launcher.action.INSTALL_SHORTCUT");
//So the shortcut doesn't get created multiple times
shortcutintent.putExtra("duplicate", false);
//UserString is the text from the user input to set the shortcut name
shortcutintent.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(UserString));
//set the icon picture
Parcelable icon = Intent.ShortcutIconResource.fromContext(getApplicationContext(), R.drawable.icon);
shortcutintent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon);
shortcutintent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, new
//Set the Activity that will be opened
Intent(getApplicationContext(), EnterActivity.class));
sendBroadcast(shortcutintent);
}
を作ることができINSTALL_SHORTCUT許可
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
を必要としています。あなたが求めていることがはっきりしていないので、あなたが本当にやろうとしていることがわかりません。
[Androidアプリのショートカットをホーム画面に追加]ボタンをクリックすると表示される可能性があります(http://stackoverflow.com/questions/10343414/add-shortcut-for-android-application-to-home-screen-on-ボタンをクリック) –
こんにちは@ラトゥル!あなたはこれを行う方法を見つけましたか? –