How to make intro activity appering only once? [closed] - android

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I just created intro sample show some tips in my app with 3 fragments and it works well but it only appears to user when I made the intro activity in manifest as "launcher" activity. So it appears every time the user opens the app.
What I need is how to make this activity appears only the first time opening the app?

You can use SharedPreferences and set value in that when User will open it for the first time. after that Every time user open the App you can check that variable. If that value is set then you can directly call next Activity.
But for this approach you have to make that <activity> with attribute android:noHistory="true". then It will work.

You can set an activity before your intro and using SharedPrefereces you can store when user open your app for the first time. In the case that is the first time you start the example activity else you start the main activity.
You can save just a boolean value SharedPreferences

Related

How to check if application exited or closed android? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I want to perform some activities like clearing cache, singletons clearing etc. I will write all this code in Service which will be background but I need this service to be triggered only when application is closed or exited.
I cant put my code to statrt service in onDestroy of activity as whenever i will move between my activities it will call onDestroy of previous activity.
How to know if application is exited.
Example will really help.
Thanks.
The ActivityManager should be what you are looking for.
For example see here
in your main activity, capture the "back" key and check for Activity.isTaskRoot() whether it is the last one. If yes, your app is going to "exit", then do some communication with your service.
please note pressing the Home key doesn't mean to "exit" your app

android press home button and re-enter my application [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
In my app, my own Application class saved some static variables, after clicked home button in my application, the screen go back to home. now i want to resume my application, when i click my app icon in launcher, the variables of the variables before are null, but onlongclick home button and choose my application, the variables is normal~
When you click app icon from the launcher at that time second instance generated for your app.To solve this issue you have to manage with single instance. For that you can use
android:launchMode="singleTask" or
android:launchMode="singleInstance"
` in your manifest for activity
Refer this question too

My app closes when screen turns off [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I got a problem with my app when the screen turns off (because of system screen timeout) my application finishes.
I search but didn't find something helpful.
Is it a common problem or does it have a fix?
you shud not call finish() in onPause. it could be called for variety of reasons(check doc.). why you want to kill your activity when user switches app? its not recommended.
here are some posts, but there is no api available to detect app going in background.
How to detect when an Android app goes to the background and come back to the foreground
http://nathanael.hevenet.com/android-dev-detecting-when-your-app-is-in-the-background-across-activities/
I want when the user leaves this activity to finish but not the screen thnx
Take finish() out of onPause(). Put it wherever the user leaves the Activity. So, assuming you have code that starts a new Activity, put finish() after startActivity().
You also could use the flag android:noHistory in your <activity> tag of your maifest.xml so that the Activity is removed from the stack whenever it starts a new Activity. Both of these methods do the same job it just depends on how you want/need to implement it.
The reason it closes when the screen turns off is because your app calls onPause() at that time so removing the call from that method would keep it from closing when the screen turns off.

I need to start an Activity immediately. how? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
in a part of my app, I need to start an Activity immediately, I mean it should immediately comes up and fills the screen but no matter if it takes some seconds to load the view and widgets(and it has no I/O operations). is there any specific thing in Android for such purpose?
for example base on this article:
On iOS, the system displays the launch image instantly when the user starts your application and until the app is fully ready to use.
that is about launch time, however. but I want to gain something like that.
I know I should optimize the onCreate method and avoid time-consuming operations in the UI thread but I'm searching for another specific way of staring an Activity immediately.
Sounds like the flow of code is causing you a problem. I would suggest putting nothing in the onCreate(). And the layout that has all of your elements set them all to gone. That way when the activity starts, you're given a blank black screen. Then turn all of your layout to visible via code and any of your start up task that were originally in the onCreate() can now be launched. You can use a tree observer to determine when the layout has filled the screen to fire something, like a method call or async task for example, to finish all of your loading.

App Introduction to user on first installation [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I wonder how google does it?? When you first power your device on, A introduction to apps and features will be shown in green color when user touches it the element will disappear ! I tried searching google but i don't get exact idea of what that layout / element was? Please regret me if this was a duplicate question.
this is definitely what you are looking for
Holo-themed transparent demo overlays
Are you just trying to do something on the first launch and then never again? Or are you looking for that look and feel? If so, it's probably just images and such layed out. If you want to test the first launch, there's a few ways to do it. One of the easiest is to create an empty file in the shared preferences in your onCreate() method, then check to see if it is there. If it's not there, you do your on first launch action and then create the file afterwards.
Check this out: Determine if android app is the first time used

Categories

Resources