私はちょうどGoogleストアにアプリをダウンロードし、それを実行していません。進行状況のダウンロードが完了すると、私のホーム画面にアプリケーションのホームショートカットが自動的に作成されます。 Googleストアのすべてのアプリは自動的にそれを行いますか?そうでない場合は?どうやってやるの? この方法では初めてでアプリを起動したとき、私はアプリのホームのショートカットを作成することができます。起動せずにアプリをインストールするときに、アプリのホームショートカットを自動的に作成できますか?
public void createOrUpdateShortcut() {
appPreferences = PreferenceManager.getDefaultSharedPreferences(this);
isAppInstalled = appPreferences.getBoolean("isAppInstalled", false);
String currentLanguage = Locale.getDefault().getDisplayLanguage();
String previousSetLanguage = appPreferences.getString("phoneLanguage", Locale.getDefault().getDisplayLanguage());
if (!previousSetLanguage.equals(currentLanguage)) {
shortcutReinstall = true;
}
if(!isAppInstalled || shortcutReinstall){
Intent HomeScreenShortCut= new Intent(getApplicationContext(),
BrowserLauncherActivity.class);
HomeScreenShortCut.setAction(Intent.ACTION_MAIN);
HomeScreenShortCut.putExtra("duplicate", false);
if(shortcutReinstall) {
Intent removeIntent = new Intent();
removeIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, HomeScreenShortCut);
String prevAppName = appPreferences.getString("appName", getString(R.string.app_name));
removeIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, prevAppName);
removeIntent.setAction("com.android.launcher.action.UNINSTALL_SHORTCUT");
getApplicationContext().sendBroadcast(removeIntent);
}
Intent addIntent = new Intent();
addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, HomeScreenShortCut);
addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, getString(R.string.app_name));
addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
Intent.ShortcutIconResource.fromContext(getApplicationContext(),
R.drawable.ic_launcher));
addIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
getApplicationContext().sendBroadcast(addIntent);
//Make preference true
SharedPreferences.Editor editor = appPreferences.edit();
editor.putBoolean("isAppInstalled", true);
editor.putString("phoneLanguage", currentLanguage);
editor.putString("appName", getString(R.string.app_name));
editor.commit();
}
をしかし、時には、ユーザーがで、すぐに私のアプリを開いていないので、私はアプリをインストールする際に起動せずにアプリのホームのショートカットを作成したいですGoogleストアでは、進行状況のダウンロードが完了した後、アプリのホームのショートカットを開いて開きます。 また別の問題があります。ホームコードのショートカットのアプリケーションタイトルは、そのコードでアプリを初めて起動したときに電話言語の変更に応じて変更される可能性があります。しかし、私はそれがすぐに起動することなく変更したい。 問題の解決方法はありますか?前もって感謝します。
Googleストアにアプリをダウンロードしただけで、まだ実行していません。進行状況のダウンロードが完了すると、自分のホーム画面にアプリケーションのホームショートカットが自動的に作成されます。 Googleストアのすべてのアプリは自動的にそれを行いますか? –
@KhoaMadridista:これはホーム画面の実装までです。 – CommonsWare
どうすればいいですか? @CommonsWare –