Android Tutorial PreferenceActivity tutorial

andrewtheart

Member
Licensed User
Longtime User
Detecting when the PreferenceActivity is closed

Hey Erel,

Is there a way to detect that the user has exited out of the Preference screen (by pressing the Back button?)

It looks like the back button keypress is being consumed by the PreferenceActivity screen.

Andrew
 

andrewtheart

Member
Licensed User
Longtime User
Nevermind - just saw that it should be handled in Activity_Resume


Hey Erel,

Is there a way to detect that the user has exited out of the Preference screen (by pressing the Back button?)

It looks like the back button keypress is being consumed by the PreferenceActivity screen.

Andrew
 

NeoTechni

Well-Known Member
Licensed User
Longtime User
I wish there was a way built in to detect when it's coming out of the preference screen, like it should call it's own event or toggle a boolean. Cause if you use more than one activity then you dont know which triggered the resume event.

What I did was set a boolean to true in the event that triggered the preference screen, so you just check that in _Resume and set it back to false.

Currently no events are available. Events can be added in the future. However you will need to handle the events from a service as your activity is paused when the preferences are displayed. This makes it a bit cumbersome.

Damn.

The only thing I could suggest then is changing it to act like an activity/service, in that it'd show up as a tab in the list of activities and we program in that. Instead of a plugin.
 
Last edited:

pinoy_ako

Member
Licensed User
Longtime User
I downloaded again the sample app from the first post. It is working great now. And something interesting i noticed in preference activty sample. When i changed the setting in the app, restarted my device, and run again the app, the setting now is the last setting before i restarted the device. Seems setting is saved automatically. I dont know where it is saved. But it is just too good feature.

Nice app.
 

latcc

Banned
demo program activity error

Noobe problem...

I am trying out the preferecesActivity library. When I try to run it on the emulator I get this error after pressing the Settings Button...

ActivityNotFoundException:
Unable to find explicit activity class {anywheresoftware.b4a.samples.preferenceactivity/anywheresoftware.b4a.objects.preferenceactivity}

I added this to the AndroidManifest.xml file:

<activity android:name="anywheresoftware.b4a.objects.preferenceactivity"/>

under the </application> tag.

What's going on here?
 

Attachments

  • prefActivity.jpg
    38.8 KB · Views: 662

latcc

Banned
Did you select Do Not Overwrite Manifest file from the Project menu?

I am simply using a modification of the demo program to understand the library so it was already selected. But comes up with this error on emulator and device. This library seems too problematic.
 

leatherguy

Member
Licensed User
Longtime User
password entry editbox

Hi Erel

I would like a password edittextbox in the preference dialog. I only can use a textbox so the password is readable, it should consist of '*' characters instead.
Is this possible?
Thanks
 

joseluis

Active Member
Licensed User
Longtime User
I would want to know how could I make PreferencesActivity Fullscreen and remove the Title bar.

I tried adding this in the Manifest editor, but it doesn't work:
B4X:
AddApplicationText(
<activity
   android:name="anywheresoftware.b4a.objects.preferenceactivity"
   android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
</activity>
)
Tried some variations of the above, without luck.
 

joseluis

Active Member
Licensed User
Longtime User
You're right! The error was elsewere (an uninitialized category), and the application crashed when the preferenceactivity was called. BTW that was the behaviour also in debug mode.

FREE TIP: If you put Theme.Light instead of Theme alone, you have a white preferences screen.
B4X:
android:theme="@android:style/Theme.Light.NoTitleBar.Fullscreen"
I'll investigate wether it's possible to further personalize its style with xml or not.

EDIT: hmm... I see the layout isn't inherited by the child preference screens.
 
Last edited:

RiverRaid

Active Member
Licensed User
Longtime User
Hi!

Sorry for the noob-question, but is it somehow possible to show this setings in a Panel?

Thx!
 

scardinal

New Member
Licensed User
Longtime User
app crashes when opening settings page

...after crash... opens fine...looks like something is stuck after i do an activity.finish and would need to be closed on application exit...which stays open...i think.

calling settings page just like you said....

StartActivity(screen.CreateIntent)

that call makes my app crash AFTER i have done an Activity.finish... when I restart app, and call that line....it crashes....any idea?
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…