I have an activity to set my preferences the first time that application get opened, but how can I change activity status (move the "MAIN" on another activity)
You cannot move the MAIN Activity to another activity at runtime. It is mandatory to define it while writing Manifest file. If you want to do that as per preferences values then check the preference value everytime and then move to your required activity.
Open SplashScreenActivity--> check preference value here-->If false go to your FirstActivity when app launched newly-->If true go to your AnotherActivity.
Hope you got the concept.
Related
first one is:
I have a setting activity and when I set my settings and I got back to Main-Activity My settings have not been applied.
Second one is:
I have a SharedPreferences in my setting activity for saving my setting.
but I don't know how can I use that when I start my app for the first time because my Shared-Preferences isn't build up yet. My SharedPreferences is in my Setting activity not in Main Activity. How can I do that?
I'm sorry if it's stupid question:)
please help.
Suppose the user is in the activity A of my application.
The user leave the application (with the home button) and at some point, while he is doing something else, I want to change the stack of my application to A B. I do not want the activity B to pop up from nowhere, I just want that when (if) the user returns to my application, he sees the activity B.
It seems that calling startActivity(B) in the activity A from a background thread works, but I’m not sure this will have the desired behaviour on every platform (what I want is that the user does not see the activity B until he returns to my application)
I may not be following this correctly
If all you are after is saving state (which activity was last active) you could use preferences Shared Preferences
You could then just have a MainActivity that does nothing other than decide which activty should be displayed the next time your application starts
Main
Using preferences find the last activity that was active
Start first activity dependent last activity ID or whatever logic you choose
Activity A or B starts/resumes etc - Store activity ID in shared preferences for retrieval later
hi all
i have an app with 3 activity. if i launch the app the first time it have to redirect to second activity from first activity. after the first time launch the app it have to go to third activity from first activity. how to do that? please help me. is there way to without using database?
Set a boolean flag in the SharedPreferences. On loading your application you can read that flag.
If it is null: goto Activity 2 and set the flag to true
If it exists: goto Activity 3
How to change main activity at application startup in Android?
I want to implement lock screen asking for password, before allow user to interact with application. Password screen can be turned of in application's settings and in such case (when application should not ask for password) I want to start Main application activity not Password activity. How it is possible?
In the onCreate of the Main activity, check preference and if password is on startActivity to load the Password activity.
First, I am new to Android programming so bear with me!
If I was doing it, I would have created another activity that would be the main activity (set in the AndroidManifest.xml file) and inside the onCreate() event I would have checked that parameter in your setting file and depending on its value, I would have launched the password activity or the other one.
I am developing an application where one of my Activity contains a button as "Set as Home Page".
So my problem is that when I will click this button the status will be saved in the shared preference and next time when this application will be opened I want to start this Activity (the Activity which has been set as home page) instead of the default one.
So how can i do it???
You need to have defined static constant unique ID for each of your Activity. You save this ID to shared preferences, and implement on your boot activity's onCreate event a switch based on this stored ID against the static constant ID of your Activity. When you have the right step start the activity, and finish your current activity the booter.
You could create a kind of redirection Activity on which your application would start on. Then, put a switch in this activity, with intents sending to each of your activities, and the state of the preference would be the variable to test for the switch.
I'm not sure I'm clear but tell me if it's fine for you?