android-lifecycle

Prevent multiple instances of my Android application composed of a single activity

萝らか妹 提交于 2019-11-28 09:54:37
I have an Android application which is composed from a single Activity . How can I assure that only one instance of my application (== Activity ) will exist in a given time? I got to a situation in which I succeeded to open multiple instances of my app by clicking on the app icon multiple times (this doesn't reproduce all the time). change your manifest like this: <activity android:name="com.yourpackage.YourActivity" android:label="@string/app_name" android:launchMode="singleTask" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent

Unable to get provider android.arch.lifecycle.LifecycleRuntimeTrojanProvider: java.lang.ClassNotFoundException

你离开我真会死。 提交于 2019-11-28 09:04:43
问题 i'm getting this class not found error on api's below 21 even though google said it supports till api 14 i have tried it on android studio 3.0 beta 6 09-19 17:12:39.273 2794-2794/? E/AndroidRuntime: FATAL EXCEPTION: main Process: xxxx, PID: 2794 java.lang.RuntimeException: Unable to get provider android.arch.lifecycle.LifecycleRuntimeTrojanProvider: java.lang.ClassNotFoundException: Didn't find class "android.arch.lifecycle.LifecycleRuntimeTrojanProvider" on path: DexPathList[[zip file "/data

Android - Activity constructor

血红的双手。 提交于 2019-11-28 07:05:41
问题 I noticed that using the shortcut Alt + Insert and selecting the builders, it tries to create a constructor with each private property (e.g. cManager and mTextView ). I remember I already created projects without it and worked correctly. The error happens when I run the application, following the full logcat and the Activity constructor: Constructor with private property: private ConnectivityManager cManager; private TextView mTextView; public SplashScreenActivity() { this.cManager =

Activity did not call finish? (API 23)

筅森魡賤 提交于 2019-11-28 05:47:09
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.app.ActivityThread.handleResumeActivity(ActivityThread.java:3134) at android.app.ActivityThread

IllegalStateException: Fragment already added in the tabhost fragment

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-28 05:37:53
FATAL EXCEPTION: main Process: com.example.loan, PID: 24169 java.lang.IllegalStateException: Fragment already added: FormFragment{428f10c8 #1 id=0x7f050055 form} at android.support.v4.app.FragmentManagerImpl.addFragment(FragmentManager.java:1192) at android.support.v4.app.BackStackRecord.popFromBackStack(BackStackRecord.java:722) at android.support.v4.app.FragmentManagerImpl.popBackStackState(FragmentManager.java:1533) at android.support.v4.app.FragmentManagerImpl$2.run(FragmentManager.java:489) at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1484) at

Android DialogFragment disappears after orientation change

我们两清 提交于 2019-11-28 04:53:57
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="orientation" but is still does not help. Here are my code samples, thank you for the help. public

Class members in Fragment become null after Home button press and wait

岁酱吖の 提交于 2019-11-28 03:37:55
问题 Problem Description Application which I'm writing has 3 Fragments. Main Fragment Activity has a Search Box with Search button when I press on a Search button the function below is called: Fragments.values()[tabControl.getCurrentItem()].getFragment().search(tv.getText().toString(), MainActivity.this.getApplicationContext()); Everything works Okay until I press HOME button wait for 30 minutes and relaunch application, after I press Search button in FragmentYellowPages Fragment application

Activity Lifecycle X Power Button X Lock Screen

巧了我就是萌 提交于 2019-11-28 02:42:13
问题 When I press the power key, the screen turns off (completely dark), the system destroys my activity and then recreates it: 03-28 22:48:00.934: V/[BB](5809): [GameControl] onPause 03-28 22:48:01.444: V/[BB](5809): [GameControl] onDestroy 03-28 22:48:01.724: V/[BB](5809): [GameControl] onCreate 03-28 22:48:03.016: V/[BB](5809): [GameControl] onResume 03-28 22:48:03.016: V/[BB](5809): [GameControl] onPause This is caused because my activity has a fixed orientation (landscape) and the lock screen

androidx.appcompat.app.AppCompatActivity doesn't implement LifecycleOwner

孤人 提交于 2019-11-28 02:01:23
I know looks like some stupid error, but I cannot find it. In my project I have access to LifecycleOwner from my Fragments but not from Activity. Here is my build.gradle implementation project(':domain') implementation project(':data') implementation fileTree(dir: 'libs', include: ['*.jar']) implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.1.1' implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.1.1' implementation 'androidx.appcompat:appcompat:1.0.2' implementation 'androidx.core:core-ktx:1

Android checking whether the app is closed

僤鯓⒐⒋嵵緔 提交于 2019-11-28 01:45:42
I have an android application i need one function or any broadcast receiver that can check if the app is closed.. i don't need to call on destroy in every activity (there is about 20 activity into the app) i tried to add this function in Application class public class ApplicationLifeCycleManager implements ActivityLifecycleCallbacks { /** Manages the state of opened vs closed activities, should be 0 or 1. * It will be 2 if this value is checked between activity B onStart() and * activity A onStop(). * It could be greater if the top activities are not fullscreen or have * transparent