Android Tutorial PreferenceActivity tutorial

corwin42

Expert
Licensed User
Longtime User
I don't see the error. Will try your code later to reproduce it.

Be aware that the AddIntent() implementation is very poor because not all information of the intent is passed. But as I can see you use similar code like in the example so it should work.
 

mitsusdev

Member
Licensed User
Longtime User

Thx a lot corwin42,
i'll wait your tests.

Regards
 

corwin42

Expert
Licensed User
Longtime User
I tried your code and it works fine here on a GB device and on a ICS emulator.

Have you tried to delete data for your app. As Erel said it looks like you have changed datatype for one setting and the app gets confused with different datatypes.
 

mitsusdev

Member
Licensed User
Longtime User
I tried your code and it works fine here on a GB device and on a ICS emulator.

Have you tried to delete data for your app. As Erel said it looks like you have changed datatype for one setting and the app gets confused with different datatypes.

Hi corwin42,
when you and Erel spoken of delete data for your app you mean to delete the application data after it is installed on the phone? Going to delete the data from application settings section?

If so I have tried many times, but when i click on settings button of my app...it crashed!:BangHead: ...but only on ICS smartphone and emulator!

...i don't know
 

mitsusdev

Member
Licensed User
Longtime User
Can you upload your project? Or the APK file?

HI Erel,
i can't upload/share project for now, because it would be unusable.

I can share a piece of my app...the piece that goes wrong when i click button that start preference Activity (..and then it crash on ICS).
The code is the same of mine.

Attached the piece of my app.

Thanks a lot
 

Attachments

  • test_activity.zip
    7.8 KB · Views: 386

mitsusdev

Member
Licensed User
Longtime User
The problem is in this line:
B4X:
manager.SetString("chktts", True)
You should use SetBoolean.

Thanks a lot Erel. Sorry for my oversight.

It work fine after apply your correction

Best Regards
 

tamadon

Active Member
Licensed User
Longtime User
It seems that while I can create two separate preference activities, the second call to manager2.GetAll.Size will return the first value manager1.GetAll.Size.

In the process global, I've declared manager1, manager2 individually.

Is it possible to have two separate PreferenceManager object?
 

elitistnot

Member
Licensed User
Longtime User
Event when user leaves setting menu

Is there an event for when the user exits the settings menu?

I want to capture that event and call a sub... anyway to do that?

Thanks.
 

EduardoElias

Well-Known Member
Licensed User
Longtime User
Hi there,

Please a little help, I have searched the forums but I am not having luck on solve this.

I have added the PreferenceManager and PreferenceScreen, it is working perfectly. I have followed the examples.

I have added a button on the activity and it shows up the PreferenceScreen and so on.

However the only thing I could not manage to work is to have the defauld android button to call the menu.

In activity_create i have added one Activity.AddMenuItem("config", "config")

Sub Config_Click
StartActivity(prefscreen.CreateIntent)
End Sub

I have added the following line on Manifest Editor:
AddApplicationText(<activity android:name="anywheresoftware.b4a.objects.preferenceactivity"/>)

I am using Android 4.0.4, b4a 2.02

How to make the default menu (3 dots) shows up for my app?

Thanks
 

EduardoElias

Well-Known Member
Licensed User
Longtime User
Yes, the standard menu button. I am suffering with the name conventions, even to ask and search. I am new on this platform.

I see on my ICS tablet, on the botton, few options: back, home, speaker volume. Somes apps makes a button appear that give access to the menu.

I dont know what is wrong since that menu button do not show up
 

EduardoElias

Well-Known Member
Licensed User
Longtime User
The menu button doesn't show when you add targetSdkVersion="14" or above to the manifest editor.

I have changed to 7 and it now is showing.

AddManifestText(
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="7"/>
<uses-permission android:name="android.permission.INTERNET" />
<supports-screens android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
AddApplicationText(<activity android:name="anywheresoftware.b4a.objects.preferenceactivity"/>)

What is the reason of that? Or guide me where to learn about that.

Thanks
 

SandroB4A

Member
Licensed User
Longtime User
Hi to all! this is my first post:sign0104:

My first app has four activities each with the same menu and I 'd like have a "setting button" in every menu.

Now I call the settings from one of this activity and all woks . Of course I want to extend functionality to the others.

My question is: wich is the best strategy to obtain that?

I must recreate every time PreferenceManager and PreferenceScreen object? or (I suppose) I can do it once?

Probably it's an obvious question, so be patient...

P.S. I didn't see properties (colors, text...) for setting screen, probably match system colors, you know some escamotage for personalising the preference screen look?
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…