activity-lifecycle

Why is secondary activity being destroyed when going back to main activity? [closed]

白昼怎懂夜的黑 提交于 2019-12-25 07:34:39
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . When going back to activity A (main activity) the activity B is being destroyed. Why is that happening? The example program I'm trying to understand is here: http://developer.android.com/shareables/training/ActivityLifecycle.zip 回答1: Here's a representation of how each new activity in a task adds an item to the

basics of android activity life cycle functions

社会主义新天地 提交于 2019-12-23 22:49:00
问题 I was testing out this code which shows which state an activity is in public class Activity101Activity extends Activity { String tag = "Lifecycle"; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // setContentView(R.layout.main); setContentView(R.layout.activity_activity101); Log.d(tag , "In the onCreate() event"); } public void onStart() { super.onStart(); Log.d(tag , "In the onStart() event");

How to handle Activity when Orientation changes?

安稳与你 提交于 2019-12-23 21:37:41
问题 I am writing an activity, that loads data from a server and displays it as a list using ArrayAdapter. For that I'm showing a progress dialog i.e loading, while it loads all data from the server. Then i dismiss the dialog in a handler. My problem is that when ever i change the orientation, the progress dialog is again shown, which is not needed, because all the data is displayed already? 回答1: I would say you have two options : Either you force your activity not to be able to change orientation

what exactly android's home button doing?

血红的双手。 提交于 2019-12-23 01:19:18
问题 What I do know is that the current activity get into the onPause() mode, and the home screen activity brought to front. My confusion starts with situation you can re-open the application from the recent tasks menu. so what exactly happening when I'm opening the application from the recent tasks manager? Is the activity that was foreground when the home button pressed is still somewhere in the stack? Is there more then one activity stack on the same time? 回答1: As far as I understand it, there

Confusion over the Android Activity Lifecycle

半腔热情 提交于 2019-12-22 09:51:01
问题 I have an app which is one activity. Everything works as I would expect except when I put the phone (a Samsung Galaxy Ace running Gingerbread) to sleep with the button on the side. When I do this, the following are called (in this order): onPause, onStop, onDestroy, onCreate, onStart, onResume, onPause . This is without waking the phone up , it is still asleep - screen is off. Why is the activity killed completely and re-recreated? Even more bizarre, if the phone is then switched back on the

onActivityResult is not called after process is killed

99封情书 提交于 2019-12-22 08:51:39
问题 I have a main activity (Main) and another activity (Sub) that is called from Main by startActivityForResult(new Intent(this, SubActivity.class), 25); When I'm at Sub, and I kill the process (using a task manager or by adb shell kill <pid> ), and I re-open the application, I'm taken immediately to Sub. In Sub I have this code to call back to the Main activity: setResult(RESULT_OK, data); finish(); I would have received the requestCode (25), the resultCode (RESULT_OK) and the data on

getRunningAppProcesses() returns processes that were destroyed

北慕城南 提交于 2019-12-22 06:56:53
问题 I am using the following snippet to check whether applications that I finish() ed are indeed no longer running: ActivityManager am = (ActivityManager)this.getSystemService(ACTIVITY_SERVICE); List<ActivityManager.RunningAppProcessInfo> procList = am.getRunningAppProcesses(); for (ActivityManager.RunningAppProcessInfo proc : procList) Log.d(TAG, proc.processName); } To my dismay, some applications that I finish() ed (in their Activity.onCreate(), even before they had a chance to launch anything

Lifecycle of a session cookie in an Android WebView / CookieSyncManager

六眼飞鱼酱① 提交于 2019-12-20 09:47:22
问题 I have an Android application which makes requests to my webserver via both a WebView and an HttpClient. I sync cookies between the two using a CookieSyncManager. So far, so good. When my application starts (inside onResume()), I run a piece of logic similar to the following: if ( appHasBeenIdleFor30Minutes() ) { CookieManager cookieManager = CookieManager.getInstance(); cookieManager.removeSessionCookie(); CookieSyncManager.getInstance().sync(); } This correctly resets any session cookies

Android: Check if activity is destroyed by a system from service

会有一股神秘感。 提交于 2019-12-20 02:55:12
问题 I have a service listening to some events from server. A service has START_STICKY flag that makes him restart when it's killed by OS. When service receive an event i have two scenarios. First, if activity isn't killed i need to send result to local broadcast receiver and update UI. Second, if it's killed by OS i want to recreate it and send data in bundle. But i don't know how to recognize that android killed my activity. onDestroy activity event doesn't come in this situation. @Override

Determine if application on foreground - is that frowned upon?

不问归期 提交于 2019-12-18 17:29:28
问题 There are lots of reasons why detecting if application is on foreground. for example - as a trigger to GCM/C2DM push notification - lot's of apps would have good reason implementing different behavior when app is foreground and background. Other reason could be - shotting down services consuming precious resources, such as querying servers in background task for instance. Just to be clear: the definition (as I see it) for background app is : application which none of it activities are invoked