android-lifecycle

What does onStart() really do? - Android [duplicate]

戏子无情 提交于 2020-01-13 05:54:11
问题 This question already has answers here : Difference between onCreate() and onStart()? [duplicate] (2 answers) Closed 5 years ago . I have been wondering for some time about the exact role of onStart() function in android life cycle. Most of the resources on net just say - it is called just before your activity becomes visible on the screen. But the applications that I have made so far I have never used onStart(). I do all my initialization in onCreate() itself. All other states in android

Android fragments vs compound controls

强颜欢笑 提交于 2020-01-11 17:41:55
问题 Why should Android 3.0 fragments be used instead of compound controls? One can create a View inheritor or compound control once and use it everywhere. I've read http://android-developers.blogspot.com/2011/02/android-30-fragments-api.html but did not find the answer. 回答1: The difference is that fragments have a life cycle (onPause, onCreate, onStart...) of their own. By having a life cycle, fragments can respond independently to events, save their state through onSaveInstanceState, and be

Android fragments vs compound controls

半城伤御伤魂 提交于 2020-01-11 17:41:47
问题 Why should Android 3.0 fragments be used instead of compound controls? One can create a View inheritor or compound control once and use it everywhere. I've read http://android-developers.blogspot.com/2011/02/android-30-fragments-api.html but did not find the answer. 回答1: The difference is that fragments have a life cycle (onPause, onCreate, onStart...) of their own. By having a life cycle, fragments can respond independently to events, save their state through onSaveInstanceState, and be

Does changing the configuration Kill the App and Restart it?

允我心安 提交于 2020-01-07 01:19:12
问题 I was reading This Tutorial section 6.1. And it says that, changing the configuration of an App causes the App to Restart? My question is, in what sense the App would Restart? does it mean that when the configuration changes, onStop() then onCreate() will be called? But this only happens when another App with higher priority needs memory! OR In the sense that, the onStop() then onRestart() then onStart() will be called? I created a sample App, with only onCreate() callback and with a Log

Android Application Lifecycle and back button

风流意气都作罢 提交于 2020-01-06 13:01:13
问题 I've read the Android Docs on the lifecycle of an activity. However, I am curious as to how different activities within an application behaves. From some tests that I've done, transitioning from Activity A to Activity B within the same application via an intent pauses Activity A via onPause() and creates Activity B via onCreate() . The strange part is when Activity B transitions back to Activity A. If the hardware back key is pressed, onPause() is fired for Activity B and onResume() is fired

Android Application Lifecycle and back button

六眼飞鱼酱① 提交于 2020-01-06 12:57:50
问题 I've read the Android Docs on the lifecycle of an activity. However, I am curious as to how different activities within an application behaves. From some tests that I've done, transitioning from Activity A to Activity B within the same application via an intent pauses Activity A via onPause() and creates Activity B via onCreate() . The strange part is when Activity B transitions back to Activity A. If the hardware back key is pressed, onPause() is fired for Activity B and onResume() is fired

Stop service on swipe to remove

泄露秘密 提交于 2020-01-05 20:55:14
问题 App killed from Recently open application list by swipe. In my application, I am running service in background only when application is available in foreground or in background . If user has sent application in background by pressing home button of mobile then also service should be run . But when user remove application from recently opened application then 1) Is any methods invoke automatically when removed from recent app list? 2) Which method will be invoke? My Requirement: when

Change EditText value when Fragment is restored from backstack

安稳与你 提交于 2020-01-04 07:17:11
问题 I have two Fragments: F1 and F2 F1 contains: an EditText that the user can fill a 'next' button to go to F2 When the user presses 'next', F2 is displayed and F1 is added to the backstack. So when the user presses back on F2 it returns to F1. When the user goes back to F1 I want to reset the value in the EditText. As I want to reinitialised the value only when the view is recreated, I reset the value in the onViewCreated and not in onResume . The problem I have is that the EditText is

How can we use menu items outside onOptionItemSelected like in onCreate()

﹥>﹥吖頭↗ 提交于 2020-01-04 04:46:07
问题 I am facing a problem in getting a reference to a menu item outside onOptionsItemSelected() method. I want that part of code to be executed as soon as my Activity is created, so I am trying to use that menu item in onCreate() but it is always returning null . Any help would be greatly appreciated. I am trying the following code: private Menu menu; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_sub_task_detail

Activity and JobIntentService Lifecycle

我怕爱的太早我们不能终老 提交于 2020-01-03 19:08:34
问题 I am running a JobIntentService to perform a task in background. The reason for using JobIntentService is that so that the user can minimize the screen while the operation is happening and even if the Android OS destroys the activity the JobIntentService will still keep running and if the user comes back he can be updated with the results. But I have a case in which suppose the user himself closes the app then I want to stop the JobIntentService also. Is there any way to notify the