지금 내 앱을 게시했으며 Android Studio를 통해 설치할 때 하나의 바로 가기 만 만드는 두 개의 바로 가기 아이콘을 만드는 것으로 나타났습니다. 나는 중복 false 및 sharedpreference를 추가하여 아이콘이 생성 된 것을 확인하는데도 사용되었습니다. 왜 앱이 다르게 작동하고 어떻게 해결할 수 있습니까? 이 바로 가기를 만들기위한 코드입니다.게시 된 앱 2 개의 바로 가기 만들기 및 디버그 1
public void createShortCut() {
SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences(StartupActivity.this).edit();
editor.putBoolean("shortcut", true).apply();
Intent shortcutintent = new Intent("com.android.launcher.action.INSTALL_SHORTCUT");
shortcutintent.putExtra("duplicate", false);
shortcutintent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "Smart App");
Parcelable icon = Intent.ShortcutIconResource.fromContext(getApplicationContext(), R.mipmap.ic_launcher);
shortcutintent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon);
shortcutintent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, new Intent(getApplicationContext(), SplashScreen.class));
sendBroadcast(shortcutintent);
}
위의 메소드를 호출하기 전에 다음과 같이 활동 시작시 실행되는 코드가 있습니다.
if (!sharedPreferences.getBoolean("shortcut", false)) {
createShortCut();
}
Play 스토어가 자동으로 바로 가기를 만듭니다. 그래서 당신도 하나를 만들어서는 안됩니다. 코드를 모두 삭제하십시오. –