2010-07-26 8 views
5

설치 후 사용자 바탕 화면에 내 응용 프로그램의 자동 아이콘 링크를 설정하는 옵션이 있는지 알고 싶습니다.바탕 화면 아이콘 링크

내가 알고있는 유일한 방법은 사용자가 응용 프로그램 목록에서 수동으로 자신의 바탕 화면으로 끌 수 있다는 것입니다. 사용자를 위해 자동으로 그 일을 할 수있는 방법이 있습니까?

감사합니다,

Moshic.

답변

4

자동으로 그렇게하지 마십시오! 사용자가 더 딱딱한 것을 선택하게하거나 자신의 바로 가기를 원하게하십시오!

 //Create shortcutIntent here with the intent that will launch you app. 
     Intent shortcutIntent = (...) 
     shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
     shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 

     final Intent intent = new Intent(); 
     intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); 
     // Sets the custom shortcut's title 
     intent.putExtra(Intent.EXTRA_SHORTCUT_NAME,sName); 
     intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, icon); 

     // add the shortcut 
     intent.setAction("com.android.launcher.action.INSTALL_SHORTCUT"); 
     sendBroadcast(intent); 

는 매니페스트에 추가 권한을 잊지 마세요 :

여기에 필요한 코드입니다!

 <uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" /> 
+0

사용자가 응용 프로그램을 설치하면 자동으로 수행 할 수 있습니까? – Moshik

+0

안드로이드에서 자체 출시 된 앱에 대해 들어 본 적이 없습니다. 애플리케이션의 첫 번째 수동 실행시이 코드를 실행할 수 있습니다. –

+0

내 응용 프로그램에 대해 수행 할 작업은 부울 기본 설정 "actiondone"을 기본적으로 "false"로 만듭니다. (! actiondone) 이 기본 설정을 true로 설정하고 "firstboot"작업을 수행합니다. 환경 설정에 익숙 하시길 ... –

관련 문제