0

is there a way to reprompt the user to choose a default activity for an intent? For example, user selects his default home apk and I want him to reconsider his choice once again.

I know how to do that on 2.1 and before, but is there a way to do that now on 2.2?

Famous Home Switcher, which did similar thing, does not work on 2.2 anymore thanks to google team

mishkin
  • 5,932
  • 8
  • 45
  • 64
  • As a user, I would find that extremely annoying. The point of picking a default is to avoid being asked every time. – Kevin Coppock Oct 19 '10 at 18:13
  • yep, I know and I completely agree. But for that particular application I need to do that. Home Switcher for example was used by a lot of people for exactly that goal - to easy switch home screen applications without going through menu and resetting default application settings. – mishkin Oct 19 '10 at 18:31
  • Oh okay. Well that does sort of make sense in that context (I've never used home switcher personally, but I could see it being useful). Unfortunately I don't really have an answer as to how you would do that. :( – Kevin Coppock Oct 19 '10 at 18:38

2 Answers2

1

This is how I represent the Activity selection dialog: It start the android default ResolverActivity for "HOME" Applications.

Intent selector = new Intent("android.intent.action.MAIN");
selector.addCategory("android.intent.category.HOME");
selector.setComponent(new ComponentName("android", "com.android.internal.app.ResolverActivity"));

startActivity(selector);

The above code is working for my 2.2 enabled tablets. When executed, it displays the "Complete Actions with:" dialog with all possible Home applications in the list.


A way to detect which is currently set by default you could ask for all preferred activities. The lists "filters" and "comps" contain the data when calling .getPreferredActivities(...).

filters - contains the intent filter data, which you could query what type of data it is.

comps - contians the component which would be called if the intent filter matches

This way you could check if your application is the current "home" application set as preferred by the user.

List<IntentFilter> filters = new ArrayList<IntentFilter>();
List<ComponentName> comps= new ArrayList<ComponentName>();
getPackageManager().getPreferredActivities(filters, comps, null);
Ronnie
  • 852
  • 12
  • 25
  • Bro when I display the promt using your Intent code, when I select an app as home screen, that app doesn't get set as default home screen. Why is that? How can I solve this? – Umer Farooq Aug 23 '13 at 14:59
0

For example, user selects his default home apk and I want him to reconsider his choice once again.

That is no longer possible, unless your app is the preferred one. Then, I think you can use clearPackagePreferredActivities() to remove yourself as the preferred choice.

In other words, you are welcome to affect your own app, but you are not welcome to affect other apps.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • yep, I use this method to release preference of my application, but I am looking for an opposite thing :) – mishkin Oct 19 '10 at 19:22
  • that Toddler Lock application is driving me crazy - it still works fine on 2.2 and the guy lock all the buttons and change preferences on the fly (it is implemented as a home screen) and when reset the preference back to user's home screen of choice. And it seems the author is google's developer :) – mishkin Oct 19 '10 at 19:24