How do you create a custom Preference which needs to invoke a "activity for result" like RingtonePreference?

by Pino Silvaggio » Fri, 13 Aug 2010 06:23:30 GMT


Sponsored Links
 Seriously, who decided or wrote this code?

PreferenceManager contains very useful methods like
"registerOnActivityResultListener" which enables you to call
startActivityForResult in your custom preference like
RingtonePreference does but it's restricted at the package level!?

So tell me, let's say I wanted a ImagePreference. How should I
proceed? I want to be able to use a activity for result intent with
the PICK action...

--



How do you create a custom Preference which needs to invoke a "activity for result" like RingtonePreference?

by TreKing » Fri, 13 Aug 2010 11:14:14 GMT


 




Hint: PreferenceActivity is an Activity like any other ...

-------------------------------------------------------------------------------------------------
TreKing < http://sites.google.com/site/rezmobileapps/treking> ; - Chicago
transit tracking app for Android-powered devices

--


Sponsored Links


How do you create a custom Preference which needs to invoke a "activity for result" like RingtonePreference?

by Pino Silvaggio » Fri, 13 Aug 2010 12:20:04 GMT


 Yes PreferenceActivity is an Activity.

But that not my problem.

The issue is how do I create a custom preference like
RingtonePreference
if what I need is in PreferenceManager and is hidden by package level?

example:

registerOnActivityResultListener

which is needed if I want to call
preferenceManager.getActivity().startActivityForResult()

which getActivity() is also hidden.

This makes no sense.





--



How do you create a custom Preference which needs to invoke a "activity for result" like RingtonePreference?

by Kostya Vasilyev » Fri, 13 Aug 2010 15:08:01 GMT


 Pino,

You can always implement your own subclass of Preference.

The same thing can be done differently inside Android and in "regular" 
applications, that's Ok.


Subclassing Preference is actually quite nice, since the base class 
handles the drawing of title and subtitle strings, so your own 
preference will automatically have the right look.


Override onClick() and do whatever it is you want to do.

-- Kostya

13.08.2010 8:19, Pino Silvaggio :
Yes PreferenceActivity is an Activity. But that not my problem. The issue is how do I create a custom preference like RingtonePreference if what I need is in PreferenceManager and is hidden by package level? example: registerOnActivityResultListener which is needed if I want to call preferenceManager.getActivity().startActivityForResult() which getActivity() is also hidden. This makes no sense.
How should I proceed?
Hint: PreferenceActivity is an Activity like any other ... ------------------------------------------------------------------------------------------------- TreKing< http://sites.google.com/site/rezmobileapps/treking> ; - Chicago transit tracking app for Android-powered devices
-- Kostya Vasilev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.com --



How do you create a custom Preference which needs to invoke a "activity for result" like RingtonePreference?

by TreKing » Fri, 13 Aug 2010 22:40:18 GMT


 On Thu, Aug 12, 2010 at 11:19 PM, Pino Silvaggio




No, it's your solution.

your Preferences, set click listeners for any of them, and call
startActivityForResult() from the PreferenceActivity to do whatever you
need. What's the problem with this?



Extend Preference, just like it does?



I don't see what you *need* this.



What makes no sense is why you feel you need to go through the
PreferenceManager functions when these two facilities are available to you
in PreferenceActivity.

-------------------------------------------------------------------------------------------------
TreKing < http://sites.google.com/site/rezmobileapps/treking> ; - Chicago
transit tracking app for Android-powered devices

--



How do you create a custom Preference which needs to invoke a "activity for result" like RingtonePreference?

by Pino Silvaggio » Fri, 13 Aug 2010 23:37:30 GMT


 This is so simple.

If I use a PreferenceActivity to handle my CustomPreference onclick()
or any other state
of a Preference added to it then the CustomPreference is worthless and
is tied to a specific activity.

It's like RingtonePreference basically doesn't do anything and you
have to explicitly write code
in PreferenceActivity to make it work.

Just look at the android sources you'll understand what I mean.
RingtonePreference handles the
activity call to pick a ringtone and save it's state.

I want to create a CustomPreference that is self-contained like any
other android preferences.






--



How do you create a custom Preference which needs to invoke a "activity for result" like RingtonePreference?

by TreKing » Fri, 13 Aug 2010 23:48:38 GMT


 On Fri, Aug 13, 2010 at 10:37 AM, Pino Silvaggio




Ah, well, this makes it clear now what you're trying to do - this was not
clear to me before, sorry.

Maybe have your CustomPreference store a reference to Activity which you set
in the PreferenceActivity onCreate?
Not completely "self-contained", but you need access to the parent Activity
*somewhere*.

-------------------------------------------------------------------------------------------------
TreKing < http://sites.google.com/site/rezmobileapps/treking> ; - Chicago
transit tracking app for Android-powered devices

--



Other Threads

1. Struggling -- SearchSuggestionSampleProvider issues

Hi

Please help me.
I am adding search suggestion in my application. When i ran only
AoiDemos/searchInvoke application, its worked fine. But when i am
added the same code in my application its giving below error when
starting application.

009-08-15 13:12:26 - MyApplication] Installing MyApplication.apk...
[2009-08-15 13:12:38 - MyApplication] Application already exists.
Attempting to re-install instead...
[2009-08-15 13:12:54 - MyApplication] Installation error:
INSTALL_FAILED_CONFLICTING_PROVIDER
[2009-08-15 13:12:54 - MyApplication] Please check logcat output for
more details.
[2009-08-15 13:12:55 - MyApplication] Launch canceled!

When i remove the below code from AndroidManifest.xml, application is
lannching fine.

<provider android:name=".search.SearchSuggestionSampleProvider"
an.droid:authorities="com.example.android.apis.SuggestionProvider" />

Can someone please help me how to resolve this issue?
Thanks in advance.

Thanks & Regards
Venkat
--~--~---------~--~----~------------~-------~--~----~

2. Strugling - How to start new intent in HelloItemizedOverlay?

Hi

I am struggling a lot. Someone please help me?
I am showing a list of locations on map. When we click on a particular
location, onTap(), i am planning to show some text message and more
information link. and on click more information, i have to show the
detailed list about that location. May be by starting a new Intent.

Can someone please help me how to do that?

Please give me some example code.
Thanks in advance.

Thanks & Regards
Venkat
--~--~---------~--~----~------------~-------~--~----~

3. How To install Hero Rom/Fw to Magic

4. Android + Google Apps

5. Activity timeout on WebView load

6. Timer not available

7. ScrollView not resizing when a a child ListView is populated