lifecycle

onNewIntent() lifecycle and registered listeners

怎甘沉沦 提交于 2019-11-27 05:58:51
I'm using a singleTop Activity to receive intents from a search-dialog via onNewIntent() . What I noticed is that onPause() is called before onNewIntent() , and then afterwards it calls onResume() . Visually: search dialog initiated search intent fired to activity onPause() onNewIntent() onResume() The problem is that I have listeners registered in onResume() that get removed in onPause() , but they are needed inside of the onNewIntent() call. Is there a standard way to make those listeners available? Rodja onNewIntent() is meant as entry point for singleTop activities which already run

Difference between Apply Request Values and Update Model Values

a 夏天 提交于 2019-11-27 05:38:46
问题 I often get doubt on these two phases. The following is my understanding: Apply Request Values In this phase, the submitted values are coming from the request parameter. Then the request values are set into the backing bean ie.setting to components UIInput Update Model Values In this phase, processed values are transferred from backing bean (UIInput) to managed beans. (It is our custom defined JSF beans). I am thinking that my understanding is correct. But, reading few articles made me

android finish() method doesn't clear app from memory

≯℡__Kan透↙ 提交于 2019-11-27 03:27:57
I have an activity and I call the finish() method and the activity is not cleared from memory. After calling finish() , I see that the method onDestroy() is executed successfully (and I clear all my variables and stuff in there). Should it be cleared from memory or its how android works? As I understand the LifeCycle of the Activity is finished. And if it keeps the app in memory so it runs faster the 2nd time the user uses it, what kind of objects can I leave in memory to reuse? If I understand correctly, I am suppose to clear everything on onDestroy. Android keeps processes around in case the

Spring request scope bean

社会主义新天地 提交于 2019-11-27 03:14:22
问题 How can I set up a bean which will created once per request. I Tried to do like this : @Component @Scope(value = "request") public class TestBean { @PostConstruct public void init() { System.out.println("start request"); } @PreDestroy public void onDestroy() { System.out.println("ends request"); } } Thanks. 回答1: Try this @Scope(value="request", proxyMode= ScopedProxyMode.TARGET_CLASS) For more details see this blog post. 回答2: You can set your bean to request scope by xml configuration as

What determines the lifecycle of a component (object graph) in Dagger 2?

。_饼干妹妹 提交于 2019-11-27 02:30:50
I'm trying to wrap my head around scopes in Dagger 2, specifically the lifecycle of scoped graphs. How do you create a component that will be cleaned up when you leave the scope. In the case of an Android application, using Dagger 1.x you generally have a root scope at the application level which you'd extend to create a child scope at the activity level. public class MyActivity { private ObjectGraph mGraph; public void onCreate() { mGraph = ((MyApp) getApplicationContext()) .getObjectGraph() .plus(new ActivityModule()) .inject(this); } public void onDestroy() { mGraph = null; } } The child

onResume() and onPause() for widgets on Flutter

扶醉桌前 提交于 2019-11-27 01:51:45
问题 Right now, a widget only has initeState() that gets triggered the very first time a widget is created, and dispose(), which gets triggered when the widget is destroyed. Is there a method to detect when a widget comes back to the foreground? and when a widget is about to go to the background because another widget just was foregrounded? It's the equivalent of onResume and onPause being triggered for Android, and viewWillAppear and viewWillDisappear for ios 回答1: The most common case where you'd

What methods are invoked in the Activity Lifecycle in the following cases:

断了今生、忘了曾经 提交于 2019-11-27 01:02:53
问题 Let's say I have a Hello World single Activity application. I start this application. What methods are invoked in each case: Home button is pressed: ? Back button is pressed: ? Phone call is received: ? What methods are invoked once the user starts the application again via the app icon (assuming the OS hasn't had a "other apps need memory condition"): Home button was pressed: ? Back button was pressed: ? Phone call was received: ? Thanks all. Edit: Extra Credit: How can the user invoke

Android Activity lifecycle and locking/unlocking device

自作多情 提交于 2019-11-27 00:36:14
问题 I just found that when the device has lock screen enabled, the followings happen. For this activity, android:screenOrientation="landscape" is set in the manifest. Then I perform the followings with my phone in a portrait mode. The user opens an activity. onCreated() is called onStart() is called onResume() is called The user LOCKS the device 4.5 onPause is called() onDestroy() is called onCreate() is called onStart() is called onResume() is called 8.5 onPause is called() The user UNLOCKS the

Automatically log Android lifecycle events using ActivityLifecycleCallbacks?

一曲冷凌霜 提交于 2019-11-27 00:22:31
I am trying to automatically capture and log Android lifecycle events using ActivityLifecycleCallbacks, however documentation on this matter is scarce, to say the least: public void registerActivityLifecycleCallbacks (Application.ActivityLifecycleCallbacks callback) I don't want to have to extend the Activity class or override the existing lifecycle methods (onCreate, onResume, etc...) I'm looking to have a separate class listening for these events and acting accordingly. Does anyone have any experience in this, or have links to good solid documentation or tutorials on how this works?

Android Application Class Lifecycle

六眼飞鱼酱① 提交于 2019-11-27 00:12:53
The android app I am working on overrides the Application class to store lightweight state (username, gps location, etc) in static vars. Most of this state is set in OnCreate of the launch activity (username retrieved from prefs, location listener runs). Is it safe to rely on the launch activity to initialize the Application class? Are there any cases where the Application class might be re-created without the Launch activity also being created? The question comes up because I ran into a null pointer exception accessing a variable in the Application class on resuming the app after the phone