2012-10-22 38 views
1

是否有可能從您的應用程序中檢測到設備上的默認啓動器應用程序?檢測默認啓動器,android

我在打包PackageManager,但似乎沒有看到我在找什麼,我想我的應用程序的啓動器類型的行爲不同,當設置爲默認啓動程序,所以我試圖以編程方式檢測是否使用已經將其設置爲默認的啓動與否

我想下面返回Android系統不管我設置爲默認的啓動代碼:

pm = getApplicationContext().getPackageManager(); 
     Intent i = (new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_LAUNCHER)); 
     final ResolveInfo mInfo = pm.resolveActivity(i, 0); 
     Log.v("curent default launcher",":::::::::"+ pm.getApplicationLabel(mInfo.activityInfo.applicationInfo)); 

回答

2

在,谷歌提供了一個啓動替換示例中的活動在清單中具有以下定義:

<activity android:name="Home" 
       android:theme="@style/Theme" 
       android:launchMode="singleInstance" 
       android:stateNotNeeded="true"> 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 
       <category android:name="android.intent.category.HOME"/> 
       <category android:name="android.intent.category.DEFAULT" /> 
      </intent-filter> 
     </activity> 

此基礎上,你應該添加下列類別查詢發射

Intent i = new Intent(Intent.ACTION_MAIN); 
i.addCategory(Intent.CATEGORY_HOME); 
i.addCategory(Intent.CATEGORY_DEFAULT);