android-lifecycle

windowIsTranslucent changes lifecycle, but error occur when entering lock screen

a 夏天 提交于 2019-12-06 10:19:14
问题 I'm experiencing that <item name="android:windowIsTranslucent">true</item> is changing the way Android Lifecycle is handled. I guess it's doing that because if the window is translucent, you can still see the underlaying activity. Let's call it activity A. Let's go through the following example where we have another activity on top of activity A. This other activity is called B. Activity A Started - This activity is the first activity Activity A Stopped - Now you start activity B. Activity B

In Android, how can I detect why my activity was resumed?

﹥>﹥吖頭↗ 提交于 2019-12-06 07:39:36
I'm developing an Activity that does some of its own state management. I'm trying to differentiate the following onResume cases: New launch task switch (home button long-click) resume after other activity in the same application wake-up after sleep orientation change Is there something in the Activity's intent, or elsewhere, that can help me differentiate these? For the curious and some context... I'd like to preserve my internal history stack on 4 & 5. On cases 2 & 3, I would preserve the same current page, but erase the history (allow the normal back button functionality to take over at that

On Android, can I register for a callback that tells me if Bluetooth is turned on or off?

痞子三分冷 提交于 2019-12-06 04:54:45
问题 I need to know inside my app whether bluetooth is on or off. Or if bluetooth was turned on or off e.g. from the OS settings pulldown menu. I thought I could do this in the Activity's onResume() . But it turns out that the activity is not paused when the Android OS's settings "pulldown menu" (the one that is accessed by pulling down with a finger from the top edge of the screen) is opened. I need to update my UI when bluetooth becomes available or unavailable. Can I register for a callback (e

Fragment's getView() returning null in a OnClickListener callback

心不动则不痛 提交于 2019-12-06 04:38:58
问题 I'm using the support library and I have a Fragment (I'll call "MyFragment") implementing a method invoked by one of the Fragment's View during an OnClick event. The OnClickListener is set in the OnActivityCreate method like this: @Override public void onActivityCreated(Bundle inState) { super.onActivityCreated(inState); ViewGroup base = (ViewGroup) getView(); TextView tv = (TextView) base.findViewById(R.id.monografiat); tv.setOnClickListener(new OnClickListener() { @Override public void

Why are lifecycle methods in activity class defined with protected access specifier

∥☆過路亽.° 提交于 2019-12-06 04:37:19
问题 Why are the lifeCycle methods in android have access specifiers as protected ? what i understand about Access-specifiers is as below :: But why should we need to make all the life-cycle methods as protected I notice this when i override the lifecycle methods I know over-riding the methods of Activity class as methods in Activity class are defined protected But why are they defined as protected 回答1: They are protected for encapsulation within the framework package android.app and subclasses.

Lifecycle when calling the fragment replace or open new activity?

╄→гoц情女王★ 提交于 2019-12-06 04:15:00
问题 The is an fragment that display the video. This fragment can either 1) open a new activity on click button 2) replace with another fragment by calling fragmentManager.beginTransaction().replace(R.id.container, f).addToBackStack(tag).commit(); for the 1) case , I would like to call player.stopPlayBack() to stop the video playing at backing And for the 2) case , I would like to call player.stopPlayBack() and player.release() to terminate the player The problem is , what event I should call for

Nexus 5 going to sleep mode makes activity life cycle buggy

半腔热情 提交于 2019-12-06 04:10:43
问题 I have a strange behavior on the Nexus 5 when going in and out to the sleep mode. It kills and relaunchs the app in a really strange way. I show you the log: Going into sleep mode (pressing the power button) 17.005: E/MotherActivity(28940): onPause called 17.025: E/MotherActivity(28940): onStop called 17.315: E/MotherActivity(28940): onDestroy called 17.365: E/GameTuto1Activity(28940): MainActivity Constructor called 17.365: E/MotherActivity(28940): onCreate called 17.695: E/MotherActivity

Application crashes on rotation without stackTrace

我的梦境 提交于 2019-12-06 02:34:46
问题 I'm having a very strange problem with my app, which consists of an Activity and 2 Fragments (android.support.v4.app.Fragment). The problem is when I rotate my tablet : the app crashes right away. A few days before, everything was working fine, but I had to change packages name, that threw a few errors but I manage to correct them. Problem appeared right after that, but I just can't find where is the error. Here is the Logcat I get right after the app is destroyed, restarted, resumed and

Why override Activity.onDestroy() if it isn't reliably called?

前提是你 提交于 2019-12-05 21:30:46
I'm confused why anyone would ever override Activity.onDestroy() instead of onPause() if according to the documentation : There are situations where the system will simply kill the activity's hosting process without calling this method (or any others) in it, I see much code that overrides onDestroy() despite this warning. Why? Why override Activity.onDestroy() if it isn't reliably called? It's not that it isn't reliably called... it's just that it isn't the only way the Activity can be killed. The Android system might trash your entire process without giving the ActivityManager the chance to

Handle app closing event from Launcher's menu

喜欢而已 提交于 2019-12-05 21:15:06
What I want to do is to know when user closes the app from Android Launcher's menu, which gets opened on home button long click: I want to do some operations when user closes the app. Actually, I want user to logout each time he leaves the app, but as long as he can close app in this was too, I have to handle this event and then make my operations. I've tried to google this one, but I couldn't find anything considering this. I don't want to override onStop() or onDestroy(), as long as the user may come back to the app then, in that case I don't have to make my changes. Don't advice this. I