Custom dialog in PreferenceActivity loaded from addPreferencesFromResource()?

by Chander Pechetty » Thu, 05 Feb 2009 18:57:08 GMT


Sponsored Links
 <DialogPreference
            android:key="yourdialogkey"
.....
...</DialogPreference>

In your PreferenceActivity class, just call
 Preference dialogPref = findPreference(yourdialogkey);

Get the dialog Layout if you are using a custom View or call one of
the SetMessage methods.
--~--~---------~--~----~------------~-------~--~----~



Custom dialog in PreferenceActivity loaded from addPreferencesFromResource()?

by g1bb » Thu, 05 Feb 2009 22:23:26 GMT


 Gotcha. I'm trying to do this in onSharedPreferenceChanged(), but I
can't seem to get it to hit.

public class Settings extends PreferenceActivity implements
OnSharedPreferenceChangeListener  {
        public static final String PREFS_NAME = "com.myapp.app_preferences";

        @Override
        public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
                settings = getSharedPreferences(PREFS_NAME, 0);

                addPreferencesFromResource(R.layout.settings);

        }

        public void onSharedPreferenceChanged(SharedPreferences
sharedPreferences, String key) {
                Log.v("changed", key);
        }

Why am I not seeing this hit when I change the preference?

Thanks again!



--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Custom dialog in PreferenceActivity loaded from addPreferencesFromResource()?

by g1bb » Wed, 11 Feb 2009 08:53:29 GMT


 Anyone have any ideas on this?

Thanks again!




--~--~---------~--~----~------------~-------~--~----~



Custom dialog in PreferenceActivity loaded from addPreferencesFromResource()?

by Chander Pechetty » Wed, 11 Feb 2009 15:01:09 GMT


 addPreferencesFromResource(R.layout.settings);
settings = getSharedPreferences(PREFS_NAME, 0);
settings.registerOnSharedPreferenceChangeListener(this);


Be sure to unregister it on onPause()



--~--~---------~--~----~------------~-------~--~----~



Custom dialog in PreferenceActivity loaded from addPreferencesFromResource()?

by g1bb » Thu, 12 Feb 2009 00:03:11 GMT


 Doh! I knew it was something simple I was forgetting.

Thanks!



--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. ACTION_BOOT_COMPLETED

Hello,

I'm new to Android. I'm trying to use the intent
android.content.Intent.ACTION_BOOT_COMPLETED in order to start a
activity/service as soon as the device is booted.The intent filter is
as below

<receiver android:name="My2Receiver" android:enabled="true">
            <intent-filter>
                <action
android:name="android.content.Intent.ACTION_BOOT_COMPLETED"/>
                <category android:name="android.intent.category.HOME"/>
            </intent-filter>
        </receiver>

Also the following is the code in My2Receiver

public void onReceive(Context context,Intent intent) {
                Log.d("DEBUG","BOOT COMPLETED");
                Intent myStarterIntent = new Intent(context, Hello.class);
        /* Set the Launch-Flag to the Intent. */
        myStarterIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        /* Send the Intent to the OS. */
        context.startActivity(myStarterIntent);
        }

But I do not see any debug messages like BOOT COMPLETED.

Target Version - Android 1.6 API Level 4.

Could anyone please help me know where I'm going wrong here.

-- 

2. android.intent.action.ANSWER

I am using android.intent.action.ANSWER for receiving my call
(android_OS). below i m giving code segment i used:

in android manifest file i wrote
 <intent-filter>
        <action  android:name="android.intent.action.ANSWER" />
        <category  android:name="android.intent.category.DEFAULT" />
  </intent-filter>

in activity class i wrote

 try
       {
          // answer the phone
          Intent myIntent = new Intent(Intent.ACTION_ANSWER);
          myIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP
                | Intent.FLAG_DEBUG_LOG_RESOLUTION
                | Intent.FLAG_FROM_BACKGROUND
                | Intent.FLAG_ACTIVITY_NEW_TASK);
          ftaContext.startActivity(myIntent);
       }
       catch (Exception e)
       {
          cleanup();
          return;
       }

But i did not get any result. Please see my code and give me a
feedback asap.

-- 

3. Tanya market nexus one yang lewat singapura

4. Android 2.1 sdk AudioManager could not control Email notifications

5. Update: WTS Nexus One BNIB, tinggal 1pc!

6. Android + C++

7. Menu stk N1