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. Rebuilding just a single external project (wpa_supplicant) - toolchain problems

I'm wanting to rebuild wpa_supplicant from source (http://
hostap.epitest.fi/wpa_supplicant/) and I'm having problems getting the
android toolchains set up so that I can properly cross-compile with
the ARM compiler and link with the proper Bionic libraries. Ideally,
I'd like to only have to build wpa_supplicant, without having to build
the platform or any other part of the android system. I would then
just push it onto the /system partition in place of the existing /
system/bin/wpa_supplicant and be able to use a modified version of the
supplicant. I've googled around quite a bit and am surprised that I
haven't been able to find instructions on how to build only a specific
external project. Therefore, I have a couple of questions:

1) Is there any reason to think that this isn't a fairly
straightforward process? Should there be any reason that I couldn't
just use the posted hostapd/wpa_supplicant source and have it fairly
effortlessly link into android?

2) How do I set the build environment with the proper cross-compilers
and include paths? I've looked at /build/envsetup.sh, but I don't know
how to get this truly configured properly. I must be missing
something.

My dev machine is ubuntu 9.04, and I'm running a modified, rooted
NexusOne with 2.6.32.

Thanks for any help - hopefully this is a trivial task and there's
documentation somewhere that I accidentally overlooked.

Joe

-- 

2. Talking to wpa_supplicant for TTLS / PEAP / TLS (Runtime+wpa_cli / JNI / LocalSocket(Unix domain socket) / wpa_supplicant.conf?)

Hi,

(I'm new to posting questions on Google Groups. Suggestions on good
posting behaviour are appreciated. :)  )

This is what I'm trying to achieve: I would like to write an Android
app that is capable of talking to wpa_supplicant. More specifically, I
would like to connect to a WPA2-EAP secured network (with
authentication methods TTLS / PEAP / TLS), but since the device will
be used by several users, the user credentials will be supplied by the
user in my app, instead of by wpa_suplicant.conf. I don't want to
write my own supplicant software, I would like to be able to
communicate with it. (I am able to connect to the network when I
provide the user credentials as well in the /data/misc/wifi/
wpa_supplicant.conf file)

I've looked at several solutions and their problems, and I would like
some advice on them. Maybe I've overlooked something:

- Solution 1: Using the Android Wifi API. Problem: The Android WiFi
API doesn't seem to support TTLS / PEAP / TLS. Strange other thing is:
It appears to support LEAP, but I can't find a way to supply the user
credentials to the WifiConfiguration.

- Solution 2: Letting the app write to /data/misc/wifi/
wpa_supplicant.conf and then reassociating. Problem: I understand from
the API that apps can only write to their own private space or the
external SD store. I've also tried writing to a file with the Terminal
Emulator app. This doesn't work. I can only write wpa_supplicant.conf
in the adb shell with root acces.

- Solution 3: Talking directly to the control interface of
wpa_suplicant using Unix domain sockets. I found that the Android API
supplies us with the LocalSocket class for this. However, I have no
idea how to cummunicate with the wpa_supplicant control interface
domain socket. (I will also post this on a wpa_supplicant forum).

- Solution 4: Using java.lang.Runtime and .Process for running wpa_cli
and communicating with it. Problem: I expect there will be
Manifest.permission conflicts.

- Solution 5: Another option might be to use Android NDK / JNI to be
able to use the helper functions in c that wpa_supplicant provides.
Problem: This might be a solution, but it seems to me that it
complicates matters a lot. And I also wonder if there might be some
Manifest.permission conflicts.

- Solution 6: Finding some open source Java supplicant code and
adapting this. Problem: I haven't found it yet. (My C skills aren't so
good).

I really need some help on this. Is there somebody with some more
experience on this topic? I hope somebody would be able to enlighten
me by providing some answers or pointers on where to look.

Any help would be greatly appreciated. Thanks in advance,

a2ronus

-- 

3. Expanding the status bar from an app (android . permission . EXPAND_STATUS_BAR?)

4. Confused about activity lifecycle usage in the notepad example

5. trusted computing

6. AudioTrack lag

7. question regarding pv player