I need to start an Activity immediately. how? [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 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.

Related

Better way of handling multiple api call in Android Kotlin [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 months ago.
Improve this question
I was working in existing application in which it has more than 5 api calls in the viewmodel through retrofit. When fetching api call it has showing loader to main screen and block user untill we get data from response. Some are dependent to each other but some are not i.e. Login session dependent on customer data etc. All response are huge in data so may be it taking time to load. I read the review from play store, its frustrations for user and giving bad reviews. This project is growing day by day. I know you guys asked why this api calls in single screen and reason behind this is the application is healthcare. We make a survey from customer and they want there results in homepage. I already read the doc and everything is up to according to doc. I don't want spoonfed, but I need guidance for you guys. Many thanks
I had a similar case where I had multiple api calls and it was so difficult to handle the ui state and dealing with loading and failure.
We can separate those api calls, there is calls that depends from each other so they can't be in parallel and there is calls that can be in parallel.
I made a loading state for each call and I separate the loading UI ( I used skeleton loader ), So each part of the UI is able to have a loading by itself not a loading state for the whole screen ( loading for the user picture, loading for posts, loading for categories... ).
And then I'm able to handle the success of each call alone, so if call 1 succeeded I will set the content related to call 1 and the other parts of the UI will remain on loading state waiting for their content, so each part of the screen is related to the calls responsible for returning the content of that part.
So no need to keep the loading state for the entire screen until all the calls finished.

Rest calls & SQLite.NET in fragment or activity [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 2 years ago.
Improve this question
I am building an Android app which uses activity and fragments and rest calls and a local database. Does anybody know where REST calls is ideal to be placed. I am more interested for fragments but would also like to know about activities as well. I also have a local SLQLite database and I have a method for getting the data. Because a database operation is long running is that similar to a REST call?
Thank you
You SHOULD NOT place long-running operations or any model logic on classes that can be destroyed by configuration changes (rotations, screen changes, phone states), these classes are designed to render the UI to the user.
You should instead use:
ViewModel (for shorter tasks, will only survive as long as the app does) and use a background thread.
https://developer.android.com/topic/libraries/architecture/viewmodel?gclid=Cj0KCQjw09HzBRDrARIsAG60GP-qiuPnYKryrX2YYZI39988xMfqTx4s6fuk5xfKtvuPZ-XQ98DxpgEaAphmEALw_wcB
Services (Recommended, can survive despite your app not being active), make sure to check out the documentation first and some examples.

app corrupts when onTouch is triggered while changing activity [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
I made a little game touch the screen to move up, release to go down. However, the player can die by colliding with the screen bounds. On collision, a new activity starts. 'Unfortunately the app has stopped' appears when I keep pressing after the collision. Using onTouchEvent.
What can I do?
I am using Eclipse, and appreciate every answer
Take a look at the code that you execute in response to the onTouch event. Can it execute if the Activity is being destroyed or has already been destroyed , e.g. are you using a background thread or an AsyncTask? You need to respect the Activity lifecycle, otherwise you may be attempting to access an Activity that is no longer in an active state.

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.

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