앱 최초실행시 바탕화면에 바로가기를 생성하였습니다.

 

생성코드는 아래와 같습니다.

 

   private void addShortcut(Context context) {
   
       Intent shortcutIntent = new Intent();
       shortcutIntent.setAction(Intent.ACTION_MAIN);
       shortcutIntent.addCategory(Intent.CATEGORY_LAUNCHER);
       shortcutIntent.setClassName(context, getClass().getName());
       shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_CLEAR_TOP);
      
       Parcelable iconResource = Intent.ShortcutIconResource.fromContext( this,  R.drawable.ic_launcher);
      
       Intent intent = new Intent();
       intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
       intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, getResources().getString(R.string.app_name));
       intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,iconResource);
       intent.putExtra("duplicate", false);
       intent.setAction("com.android.launcher.action.INSTALL_SHORTCUT");      
       sendBroadcast(intent);
      
  }

 

위 코드로 바탕화면에 shortcut이 생성 되었는데 문제가 생겼습니다.

 

일단 앱을 실행후 앱을 사용하다가  홈버튼을 눌러 빠져나옵니다.

 

이상태에서 프로그램 리스트에 있는 아이콘을 클릭하면 저장된 히스토리를 기억해서 마지막 사용했던 화면이 그대로 뜹니다.

 

그런데

 

바탕화면에 설치한 shorcut아이콘을 클릭하면 초기시작이 됩니다. 재시작 되는 것같은데요..

 

프로그램 리스트에서 아이콘을 바탕화면으로 가져오기해서 만들어진 shorcut은 정상작동 됩니다.

 

 

왜 위 코드로 생성한 아이콘으로 앱을 실행하면 히스토리를 기억하지 못하고 처음시작(재시작)이 되는 걸까요?

 

안드로이드 개초보라 전체적인 개념이 잡혀있질 않다보니 하나하나 할때마다 난관에 봉착하네요.

 

도움좀 부탁드려요 ㅠㅠ.