App exits instead of going to next activity

4

I am calling an activity through a simple intent:

Intent startNewActivityOpen2 = new Intent(this, TransitionLandscape.class);
if (extras != null) {
        if (!extras.isEmpty()) {

           startNewActivityOpen2.putExtras(extras);
        }
}

startActivity(startNewActivityOpen2);

Does it matter that this current activity is also TransistionLandscape.class? The app exits (without crashing) when I start the new activity. Going through the debugger, the new activity is never called: (onCreate in is never called)

From the documentation, it seems that an activity can call itself.

Logcat:

12-10 21:08:23.410 543-553/? I/ActivityManager: START u0
{cmp=com.assistek.ediary/.TransitionLandscape (has extras)} from pid
4801
12-10 21:08:23.470 543-573/? D/dalvikvm: GC_FOR_ALLOC freed 437K, 18% free 14435K/17524K, paused 51ms, total 52ms
12-10 21:08:23.490 4801-4801/com.assistek.ediary D/Base Activity: **********Pause class com.assistek.ediary.TransitionLandscape
    **********Pause Navigate: true
    **********Resume class com.assistek.ediary.TransitionLandscape
    **********Focus: false Activity: class com.assistek.ediary.TransitionLandscape
12-10 21:08:23.500 4801-4801/com.assistek.ediary D/Base Activity: **********Pause class com.assistek.ediary.TransitionLandscape
    **********Pause Navigate: false
12-10 21:08:23.520 543-600/? I/InputReader: Reconfiguring input devices.  changes=0x00000004
    Device reconfigured: id=2, name='elan-touchscreen', size 800x1280, orientation 0, mode 1, display id 0
12-10 21:08:23.520 543-1012/? I/ActivityManager: Config changes=480 {1.0 310mcc170mnc en_US ldltr sw600dp w600dp h880dp 213dpi
lrg port finger -keyb/v/h -nav/h s.11}
12-10 21:08:23.540 961-961/? I/PCKeyboard: onConfigurationChanged()
12-10 21:08:23.580 543-561/? I/WindowManager: Screen frozen for +74ms due to Window{425793b8 u0 com.assistek.ediary/com.assistek.ediary.TransitionLandscape}
12-10 21:08:23.600 634-634/? D/PhoneStatusBar: mSettingsPanelGravity = 8388661
12-10 21:08:23.690 543-1045/? I/ActivityManager: Killing 1995:com.google.android.setupwizard/u0a50 (adj 15): empty #17
12-10 21:08:23.720 4801-4801/com.assistek.ediary W/IInputConnectionWrapper: showStatusIcon on inactive InputConnection
12-10 21:08:23.730 4801-4801/com.assistek.ediary D/Base Activity: **********Stop Navigate Away false
    **********Stop class com.assistek.ediary.TransitionLandscape
    **********Stop Focus ToClass class com.assistek.ediary.TransitionLandscape
    Task ID 151
    **********Destroy class com.assistek.ediary.TransitionLandscape
12-10 21:08:23.740 4801-4801/com.assistek.ediary D/Time calculation:: Destroy: class
com.assistek.ediary.TransitionLandscape
12-10 21:08:25.660 543-561/? D/dalvikvm: GC_EXPLICIT freed 287K, 18% free 14449K/17524K, paused 8ms+5ms, total 78ms
12-10 21:08:26.430 543-600/? I/InputReader: Reconfiguring input devices.  changes=0x00000004
    Device reconfigured: id=2, name='elan-touchscreen', size 800x1280, orientation 1, mode 1, display id 0
12-10 21:08:26.430 543-566/? I/ActivityManager: Config changes=480 {1.0 310mcc170mnc en_US ldltr sw600dp w961dp h528dp 213dpi lrg land
finger -keyb/v/h -nav/h s.12}
12-10 21:08:26.460 961-961/? I/PCKeyboard: onConfigurationChanged()

Also, calling:

recreate() 

instead of going to new activity, also causes app to exit (without a crash).

EDIT: Manifest

        <activity
        android:name=".TransitionLandscape"
        android:configChanges="orientation"
        android:label="@string/app_name"
        android:launchMode="singleTask"
        android:screenOrientation="landscape"
        android:windowSoftInputMode="stateHidden">
    </activity>

Actually, any activity that I call after TransitionLandscape causes the app to exit. Is it a memory problem?

android
android-intent
android-activity
asked on Stack Overflow Dec 30, 2018 by Kristy Welsh • edited Jan 2, 2019 by Kristy Welsh

5 Answers

2

Your app is crashing after that intent, as configuration changed is received.

12-10 21:08:23.520 543-600/? I/InputReader: Reconfiguring input devices.  changes=0x00000004
    Device reconfigured: id=2, name='elan-touchscreen', size 800x1280, orientation 0, mode 1, display id 0
12-10 21:08:23.520 543-1012/? I/ActivityManager: Config changes=480 {1.0 310mcc170mnc en_US ldltr sw600dp w600dp h880dp 213dpi
lrg port finger -keyb/v/h -nav/h s.11}
    12-10 21:08:23.540 961-961/? I/PCKeyboard: onConfigurationChanged()
12-10 21:08:23.740 4801-4801/com.assistek.ediary D/Time calculation:: Destroy: class
com.assistek.ediary.TransitionLandscape

can you try with

android:configChanges="orientation|screenSize|keyboardHidden" />

There are other ways also to handle configuration changes you can check this link

answered on Stack Overflow Jan 3, 2019 by nkalra0123
1

Request you to please change below lines.

android:configChanges="orientation"

To

android:configChanges="orientation|screenSize|keyboardHidden" />

In your manifest file.

answered on Stack Overflow Jan 7, 2019 by Akshay Sharma • edited Jan 7, 2019 by JustBaron
0

I think you should try deleting the "Adding Extras code block" to know that if problem start from it or you can also modify your TransitionLandScape activity a bit, for example deleting launchMode = "singleTask" tag in Manifest file, ... then run app again to check that did you solve the problem. It just my opinion and i am not good much at English, sorry if there is any grammar error.

answered on Stack Overflow Dec 30, 2018 by Tăng Tấn Tài
0

it is not memory problem,

this line of your log clearly say's that you have problem when change orientation of activity (onConfigurationChanged())

WindowManager: Screen frozen for +74ms due to Window

in manifest file it will not allow to recreate activity on changing orientation of your device

try to change/set app orientation with code on recreate() method or in onCreate() method

setRequestedOrientation(Configuration.ORIENTATION_LANDSCAPE);
answered on Stack Overflow Jan 7, 2019 by Rj_Innocent_Coder
-1

Use different names for your activities.

answered on Stack Overflow Dec 30, 2018 by Habib Mhamadi

User contributions licensed under CC BY-SA 3.0