B4A Library AHPreferenceActivity Library

This Library is based on Erels PreferenceActivity Library and adds some hopefully useful things:

  • Checkbox entry can show On and Off summary
  • Dependencies to other entries
  • Another Listview type with Map as value/displayvalue pairs
  • AddPassword() for password entries
  • AddRingtone() for selecting notification, ringtone or alert sound

V1.01:
  • Bugfix for FC with nested PreferencesScreens
  • Added support for calling Intents (other activities)
  • Preferencescreens support dependency

V1.02:
  • Bugfix for GetUpdatedKeys not working sometimes (thanks, Erel)

V1.03:
  • Never published

V1.04:
  • Added AddEditText2() method with support for InputType and some other properties
  • !!! Changed package name to "de.amberhome.objects" !!! Change in your Manifest!

For a tutorial see PreferenceActivity Tutorial
 

Attachments

Last edited:
Hi,
I'm using the AddList2 method to show a set of choices. Is there any way to show the selected choice as the subtitle on the settings screen after selection?
Thanks
Andrew
 
HI, no plans to add a user picture selection ?
 
Hi,
Is there any way to trigger an event when a user either clicks on a certain setting, or when a setting changes? I'd like to trigger some onward processing, but I'd prefer not to have to create a dummy intent with all that entails. One of Erel's posts suggested that this library provides some change events, but I can't see how this works.

Thanks
Andrew
 
Is there any way to trigger an event when a user either clicks on a certain setting, or when a setting changes? I'd like to trigger some onward processing, but I'd prefer not to have to create a dummy intent with all that entails. One of Erel's posts suggested that this library provides some change events, but I can't see how this works.

No, events are not possible.
 
I'm not 100% sure but i think there's a bug in the new Lib Version 1.04 in setActivity cause firs i downloaded 1.02 and it was working fine but when i downloded 1.04 it stopped working , but still One of the amazing Libs out there amazing work , thanks ;)


P.S i didn't change anything in the code just updated the Lib and it stopped working
 
I'm not 100% sure but i think there's a bug in the new Lib Version 1.04 in setActivity cause firs i downloaded 1.02 and it was working fine but when i downloded 1.04 it stopped working , but still One of the amazing Libs out there amazing work , thanks ;)


P.S i didn't change anything in the code just updated the Lib and it stopped working

See the changelog in first post. The package name was changed to prevent conflicts with other libraries. You have to change it in the manifest of your project, too.
 
See the changelog in first post. The package name was changed to prevent conflicts with other libraries. You have to change it in the manifest of your project, too.
Thanks for the reply , infact i didn't change it at firs but when i run the app it showed an exception when trying to get into the preference screen and after i saw it i changed the package name and i got into the preference without any errors except the setActivity was not working :(

so i should have wrote in the first post that i changed the package name lol sorry
 
Thanks for the reply , infact i didn't change it at firs but when i run the app it showed an exception when trying to get into the preference screen and after i saw it i changed the package name and i got into the preference without any errors except the setActivity was not working :(

so i should have wrote in the first post that i changed the package name lol sorry

What setActivity are you talking about?
 
Hello!!

I use the AHPreference-lib to set some passwords. But I have seen, that the dictionary saves the passwords, even though I used 'addpassword'.
I know, that it is possible to prevent this with the following code. Is it possible to combine this with the password-mode of the perference?

Code: Copy
PasswortFTP.InputType=Bit.OR(PasswortFTP.InputType,0x00000080)

Thanks for help...
 
O.k, I have found a way with the SLInpTypeConst-Class:

Code: Copy
Dim InpTyp As SLInpTypeConst
InpTyp.Initialize
Cat_FTP.AddEditText2("PasswortFTP", "Passwort", "Passwort für FTP-Zugang eingeben", "", InpTyp.TYPE_NUMBER_VARIATION_PASSWORD, True, False, "")

Greetings....
 
Hey, my app crashes when I open the AHPreferenceActivity while the device is in landscape mode, is this a common problem? Is there a fix available?
 
Hey, my app crashes when I open the AHPreferenceActivity while the device is in landscape mode, is this a common problem? Is there a fix available?

Works without problem here.

Do you have a stack trace?
 
Probably not since I don't know what that is :)

The complete error message and a logcat snippet from the error.

No one can guess what "my app crashes" means.
 
The complete error message and a logcat snippet from the error.

No one can guess what "my app crashes" means.

No actual error message pops up on my phone, only that the app has stopped working.

http://i.gyazo.com/02ca72891bf12dac7d2934658c452aeb.png

First line is
Code: Copy
java.lang.RuntimeException: Unable to start activity ComponentInfo{b4a.example/de.amberhome.objects.preferenceactivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.Iterator java.util.ArrayList.iterator()' on a null object reference

Also, what is the Dependency when creating views in a PreferenceScreen and what should I have there?

Sorry, these are probably all stupid questions, I'm new :/
 
No actual error message pops up on my phone, only that the app has stopped working.

http://i.gyazo.com/02ca72891bf12dac7d2934658c452aeb.png

No actual error message pops up on my phone, only that the app has stopped working.

http://i.gyazo.com/02ca72891bf12dac7d2934658c452aeb.png

First line is
Code: Copy
java.lang.RuntimeException: Unable to start activity ComponentInfo{b4a.example/de.amberhome.objects.preferenceactivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.Iterator java.util.ArrayList.iterator()' on a null object reference

Also, what is the Dependency when creating views in a PreferenceScreen and what should I have there?

Sorry, these are probably all stupid questions, I'm new :/

First line is
Code: Copy
java.lang.RuntimeException: Unable to start activity ComponentInfo{b4a.example/de.amberhome.objects.preferenceactivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.Iterator java.util.ArrayList.iterator()' on a null object reference

Also, what is the Dependency when creating views in a PreferenceScreen and what should I have there?

Do you have the preference activity declared in the manifest editor? You have to add

Code: Copy
AddApplicationText(<activity android:name="de.amberhome.objects.preferenceactivity"/>)

there.

With the dependency you can make dependent settings. So when you uncheck a checkbox setting all dependent settings will be grayed out. I think the usage is in the example. If you don't need this feature just enter an empty string as parameter.
 
Do you have the preference activity declared in the manifest editor? You have to add

Code: Copy
AddApplicationText(<activity android:name="de.amberhome.objects.preferenceactivity"/>)

there.

With the dependency you can make dependent settings. So when you uncheck a checkbox setting all dependent settings will be grayed out. I think the usage is in the example. If you don't need this feature just enter an empty string as parameter.

I already have both of those. The crash only happens in landscape mode. When my phone is in portrait mode, I have no problem opening the settings screen :/
 
Back
Top