[android-developers] Clear defaults programmatically

Showing 1-9 of 9 messages
[android-developers] Clear defaults programmatically Bonifaz 4/16/10 2:09 AM
Does anyone know
how to clear defaults of my own app by code.

I know that a user can always go to Manage Applications, find my app
and click the button there to clear previously assigned default
actions. But for most users this isn't intuitive at all.

I would like to offer my customers a solution to clear defaults within
my own app if they don't like to use my app as a replacement for a
specific action anymore.

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-d...@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Clear defaults programmatically Menion 4/18/10 6:01 AM
I'm using this code ... hope it helps

PreferenceManager.getDefaultSharedPreferences(context).edit().clear().commit();
[android-developers] Re: Clear defaults programmatically Bonifaz 4/18/10 6:01 PM
This clears the preferences, but not the default flag set by a user
when a Intent Chooser is shown to him/her.
Am I right?

How can I get back the Intent Chooser Dialog when a user previously
set my app as default. I know you can go to Manage Applications and
click "clear defaults" but how do I do this in code?

On Apr 18, 3:01 pm, Menion <menion.as...@gmail.com> wrote:
> I'm using this code ... hope it helps
>
> PreferenceManager.getDefaultSharedPreferences(context).edit().clear().commi t();
>
Re: Clear defaults programmatically Bonifaz 5/28/10 10:51 AM
Is it even possible?
No one knows this?

I suppose many users don't know how to do this on their phones,
because it is rather complicated to understand for non programmers.
I want to give my users the option to clear defaults of my app, within
my app.

But how do I do this?
Re: [android-developers] Clear defaults programmatically skink 5/28/10 11:17 AM


Bonifaz wrote:
> Does anyone know
> how to clear defaults of my own app by code.
>
> I know that a user can always go to Manage Applications, find my app
> and click the button there to clear previously assigned default
> actions. But for most users this isn't intuitive at all.
>
> I would like to offer my customers a solution to clear defaults within
> my own app if they don't like to use my app as a replacement for a
> specific action anymore.
>
>

http://developer.android.com/intl/fr/reference/android/preference/PreferenceManager.html#setDefaultValues(android.content.Context,
int, boolean)

pskink
Re: [android-developers] Clear defaults programmatically TreKing 5/28/10 11:37 AM
On Fri, May 28, 2010 at 1:17 PM, skink <psk...@gmail.com> wrote:
http://developer.android.com/intl/fr/reference/android/preference/PreferenceManager.html#setDefaultValues(android.content.Context, int, boolean)

This is not what the OP is asking - when you execute an action, if there are multiple activities that support that action you can choose which to use and optionally set it as the default handler of that action.

For example, if you have two browsers and click a link, you can choose which to use and set one as the default so it's always called instead of giving you the choice. However, if you later decide you no longer want that activity to handle that action by default, you have to go through the preferences, select the app that is the default for that action, and hit a button to clear it as the default handler for that action.

The OP wants to know if there is a way to programmatically do the equivalent of going through those steps.

This has nothing to do with an app's own preferences.

OP - I don't know if this is possible, but as a next best thing you could possibly tell the user what they have to do and then open the manage application's settings page for them and let them finish the process.

-------------------------------------------------------------------------------------------------
TreKing - Chicago transit tracking app for Android-powered devices
http://sites.google.com/site/rezmobileapps/treking
Re: [android-developers] Clear defaults programmatically Mark Murphy 5/28/10 11:42 AM
TreKing wrote:
> OP - I don't know if this is possible, but as a next best thing you
> could possibly tell the user what they have to do and then open the
> manage application's settings page for them and let them finish the process.

PackageManager has clearPackagePreferredActivities(). However, you can
only clear places where your own app has been made a preferred activity
-- you cannot attack other applications this way.

--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Warescription: Three Android Books, Plus Updates, One Low Price!

Re: Clear defaults programmatically Bonifaz 5/28/10 11:43 AM
Thanks TreKing,

this is exactly what I meant. And thank you for your tip. I already
have a description of how to do this manually, but never thought about
opening the manage application activity. If there is no other way I
will head for your proposed work around.


On May 28, 8:37 pm, TreKing <treking...@gmail.com> wrote:
> On Fri, May 28, 2010 at 1:17 PM, skink <psk...@gmail.com> wrote:
>
> >http://developer.android.com/intl/fr/reference/android/preference/Pre..., int,
Re: [android-developers] Clear defaults programmatically skink 5/31/10 3:41 PM


TreKing wrote:
> On Fri, May 28, 2010 at 1:17 PM, skink <psk...@gmail.com> wrote:
>
> >
> > http://developer.android.com/intl/fr/reference/android/preference/PreferenceManager.html#setDefaultValues(android.content.Context, int,
> > boolean)
>
>
> This is not what the OP is asking - when you execute an action, if there are
> multiple activities that support that action you can choose which to use and
> optionally set it as the default handler of that action.
>
> For example, if you have two browsers and click a link, you can choose which
> to use and set one as the default so it's always called instead of giving
> you the choice. However, if you later decide you no longer want that
> activity to handle that action by default, you have to go through the
> preferences, select the app that is the default for that action, and hit a
> button to clear it as the default handler for that action.
>
> The OP wants to know if there is a way to programmatically do the equivalent
> of going through those steps.
>
> This has nothing to do with an app's own preferences.
>
>

oh yes, my apologies, i was to quick reading just the first paragraph

pskink