Android: change default Home Application Android: change default Home Application android android

Android: change default Home Application


I did an extensive research on that and starting from 2.2 there is no way to do that. The only way is using some hacking that toddler lock app does but this app put samsung phones recently in the infinite loop, so it is a risky approach.

if you look at the froyo source code here of packagemanager class, you will see this small condition in the addPreferredActivity method:

if (getUidTargetSdkVersionLockedLP(Binder.getCallingUid())                     < Build.VERSION_CODES.FROYO) {                 Slog.w(TAG, "Ignoring addPreferredActivity() from uid"                        + Binder.getCallingUid());                 return;             }

HomeSwitcher does not work properly on 2.2 since it uses this very method and developer made a comment on app page "Froyo(2.2) is not supporteddue to the API change"


"Result set changed" means that the set of packages matching that intent has changed from the set you specified when you created the default - - so the default is no longer valid. Your list of components (which you are currently setting to null) needs to contain all homescreen apps present on device, not just yours.

Here's example code that I have tested (using adb shell am start http://www.google.co.uk/ ) and used to set the default browser. XXX represents a customer name that I had to black out.

Note that in order to call addPreferredActivity you must have compiled against a minimum-sdk version of 8 (2.2) and you must have specified the SET_PREFERRED_APPLICATIONS permission. That permission is protection level 2, so you need to be signed with the same certificate as PackageManager.

IntentFilter filter = new IntentFilter();filter.addAction("android.intent.action.VIEW");filter.addCategory("android.intent.category.DEFAULT");filter.addDataScheme("http");Context context = getApplicationContext();ComponentName component = new ComponentName("com.opera.mini.XXX", "com.opera.mini.XXX.CustomerBrowser");ComponentName[] components = new ComponentName[] {new ComponentName("com.android.browser", "com.android.browser.BrowserActivity"),                                                  component};pm.addPreferredActivity(filter, IntentFilter.MATCH_CATEGORY_SCHEME, components, component);

ETA - if you marked this response down, could you let me know why. The code I posted above is tested and working...


startActivity(new Intent(Settings.ACTION_HOME_SETTINGS));