android-lifecycle

when is onRestoreInstanceState called?

独自空忆成欢 提交于 2019-11-27 07:46:40
Sorry for my incomprehension, but I am new in the android development. I have an application with activity A and activity B in it, and I go from activity A to activity B. When I left activity A, the onSaveInstanceState method was called, but when I went back to activity A (from activity B in the same application), the bundle in the onCreate method was null. What can I do, to save the activity A's previous state? I only want to store the data for the application lifetime. Can someone help me with this? Here is my code for Activity A: @Override protected void onCreate(Bundle savedInstanceState)

Activity Transition Animations in Android

橙三吉。 提交于 2019-11-27 07:04:52
问题 I want to apply an activities transition like the one that HTC phones have: When you start a new Activity there is a slide right-to-left, but when you press the back button to return to the previous Activity, there is a slide left-to-right animation. I have used overridePendingTransition in the onResume of my Activities to simulate the slide right to left animation, but when I press the back button, the same animation is executed which is wrong (from a result perspective). Thus I would like

How to handle AsyncTask onPostExecute when paused to avoid IllegalStateException

那年仲夏 提交于 2019-11-27 06:11:31
I appreciate the numerous postings regarding AsyncTask on a rotation change. I have the following problem when using the compatability lib and trying to dismiss a DialogFragment in onPostExecute . I have a fragment which fires of an AsyncTask which displays a progress DialogFragment , then in onPostExecute dismisses the dialog and then potentially throws up another DialogFragment . If when the progress dialog is being displayed I put the application into the background I get the following for my fragment: 1) onPause 2) onSaveInstanceState 3) onPostExecute in which I try to dismiss and invoke a

Android Fragment onCreateView vs. onActivityCreated

社会主义新天地 提交于 2019-11-27 06:11:09
I know that a fragment's view hierarchy has to be inflated in onCreateView, but what other functionality can be in onCreateView vs. what should wait for onActivityCreated? My current implementation uses separate activities for everything, and a typical activity does most of its work in its onCreate method, including inflating the view, setting the content view, initializing the various widgets with data, setting up listeners, etc. So can this probably all be moved into onCreateView, or should some functions be put into an onActivityCreated method instead? If your view is static, then moving

Activity.finish() called but activity stays loaded in memory

女生的网名这么多〃 提交于 2019-11-27 05:05:40
When I run my app on the debugger, I get the main thread and 3 binder threads. On a button click I call Activity.finish() , which looks like it ends the activity as the UI closes and goes back to the home screen. However, in the debugger, it still shows the main thread and 3 binder threads as " (running) ". I am baffled to why this is happening. Even more so, it is causing my app to call Activity.onResume() when I run it again after exiting the app. I currently override these methods in the Activity, but I call the appropriate super functions in each one: onDestroy() onPause() onResume()

Prevent activity from being destroyed as long as possible

橙三吉。 提交于 2019-11-27 04:45:50
问题 I have an app, a single activity app with fragments in it. The usual use case for this app is, that you start it and put the phone away and every now and then, you get back to the phone and insert some data... It's a logging app, you are doing something and insert your results into the app... I have the problem, that every now and then, my activity get's destroyed and is recreated with an empty bundle... (Most of the time this is not the case, but every now and then this happens...). My app

fragment lifecycle: when “ondestroy” and “ondestroyview” are not called?

允我心安 提交于 2019-11-27 01:48:56
Imagine this scenario: I have a Fragment in a Pager . I try to switch to other apps, so that the Activity owning my pager (and my fragment) will be stopped and temporarily destroyed, eventually. So, when I come back to my Activity, the Fragment 's callbacks onCreate , oncreateview and so forth are called. But none of the Fragment's onDestroy callbacks were called before! It seems that after "onStop" the fragment is destroyed at once. Is it a normal behavior? Is it maybe because the Activity is destroyed without a call to its onDestroy ? invertigo Take a look at this question: Why implement

Android - Preserve or delete files created by the application on uninstall

纵饮孤独 提交于 2019-11-27 01:26:16
I created an application which creates and stores files to sdcard. Is there a way to bind the folder with application in order to delete all files when the user runs uninstall on android device? Prashast There's no way for your application to know that it is being uninstalled (without modifying the kernel). All files created in the data/data/your.app.package is deleted automatically upon application uninstall. I don't think anything is cleared from the sdcard. You can do a quick test and find that out. Another approach could be to have another application that checks whether this application

Activity did not call finish? (API 23)

泪湿孤枕 提交于 2019-11-27 01:09:28
问题 I am getting the following error and i have no clue as to why its happening. Error: 08-23 17:07:46.533 22454-22454/com.a.b.c E/AndroidRuntime﹕ FATAL EXCEPTION: main Process: com.a.b.c, PID: 22454 java.lang.RuntimeException: Unable to resume activity {com.a.b.c/com.a.b.c.MainActivity}: java.lang.IllegalStateException: Activity {com.a.b.c/com.a.b.c.MainActivity} did not call finish() prior to onResume() completing at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3103) at

Android DialogFragment disappears after orientation change

余生颓废 提交于 2019-11-27 00:42:15
问题 I have a FragmentActivity support v4 class which implements two side by side (kind of like gmail) fragments and a button which can bring up a DialogFragment. This all works great unless I have an orientation change. When I have an orientation change the states of the Fragments are not saved. And the main problem is if I have a the FragmentDialog open, it simply disappears. I have set setRetainInstance(true); in all fragments but it did not help. In my manifest I included android:configChanges