6

I am trying to add a night mode to my app but the app just closes each time it switches between day/night modes on my main screen. It just closes out the app, no error, no crash, no log cat data, just closes. Has anyone seen this happen before and is there a better way I can see why?

AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);

Here is the data from my debug session:

V/FA: Activity resumed, time: 455508700
V/FA: Connection attempt already in progress
D/ViewRootImpl@560a619[dashboard]: setView = DecorView@ae2f610[dashboard] TM=true MM=false
D/ViewRootImpl@560a619[dashboard]: Relayout returned: old=[0,0][1080,2280] new=[0,0][1080,2280] req=(1080,2280)0 dur=11 res=0x7 s={true 540690239488} ch=true
D/OpenGLRenderer: createReliableSurface : 0x7e71cddc80, 0x7de3a65000
D/OpenGLRenderer: SurfaceChanged : 0x0 -> 0x7e109da080
E/ViewRootImpl: sendUserActionEvent() mView returned.
I/TextToSpeech: Connected to ComponentInfo{com.samsung.SMT/com.samsung.SMT.SamsungTTSService}
W/m.mydrive: Accessing hidden method Lsun/misc/Unsafe;->getInt(Ljava/lang/Object;J)I (greylist, linking, allowed)
D/FA: Connected to remote service
V/FA: Processing queued up service tasks: 3
I/TextToSpeech: Set up connection to ComponentInfo{com.samsung.SMT/com.samsung.SMT.SamsungTTSService}
D/ViewRootImpl@560a619[dashboard]: Relayout returned: old=[0,0][1080,2280] new=[0,0][1080,2280] req=(1080,2280)0 dur=6 res=0x1 s={true 540690239488} ch=false
D/ViewRootImpl@560a619[dashboard]: MSG_WINDOW_FOCUS_CHANGED 1 1
D/InputMethodManager: prepareNavigationBarInfo() DecorView@ae2f610[dashboard]
getNavigationBarColor() -855310
D/InputMethodManager: prepareNavigationBarInfo() DecorView@ae2f610[dashboard]
getNavigationBarColor() -855310
V/InputMethodManager: Starting input: tba=com.mydrive ic=null mNaviBarColor -855310 mIsGetNaviBarColorSuccess true , NavVisible : true , NavTrans : false
D/InputMethodManager: startInputInner - Id : 0
I/InputMethodManager: startInputInner - mService.startInputOrWindowGainedFocus
D/InputTransport: Input channel destroyed: 'ClientS', fd=239
W/m.mydrive: Accessing hidden method Lsun/misc/Unsafe;->getInt(Ljava/lang/Object;J)I (greylist, linking, allowed)
D/ViewRootImpl@560a619[dashboard]: MSG_RESIZED: frame=[0,0][1080,2280] ci=[0,108][0,126] vi=[0,108][0,126] or=1
W/m.mydrive: Accessing hidden method Lsun/misc/Unsafe;->getObject(Ljava/lang/Object;J)Ljava/lang/Object; (greylist, linking, allowed)
W/m.mydrive: Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed)
Accessing hidden method Lsun/misc/Unsafe;->putLong(Ljava/lang/Object;JJ)V (greylist, linking, allowed)
Accessing hidden method Lsun/misc/Unsafe;->putObject(Ljava/lang/Object;JLjava/lang/Object;)V (greylist, linking, allowed)
W/m.mydrive: Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed)
W/m.mydrive: Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed)
Accessing hidden method Lsun/misc/Unsafe;->getObject(Ljava/lang/Object;J)Ljava/lang/Object; (greylist, linking, allowed)
W/m.mydrive: Accessing hidden method Lsun/misc/Unsafe;->getObject(Ljava/lang/Object;J)Ljava/lang/Object; (greylist, linking, allowed)
W/m.mydrive: Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed)
Accessing hidden method Lsun/misc/Unsafe;->getObject(Ljava/lang/Object;J)Ljava/lang/Object; (greylist, linking, allowed)
W/m.mydrive: Accessing hidden method Lsun/misc/Unsafe;->getObject(Ljava/lang/Object;J)Ljava/lang/Object; (greylist, linking, allowed)
W/m.mydrive: Accessing hidden method Lsun/misc/Unsafe;->getObject(Ljava/lang/Object;J)Ljava/lang/Object; (greylist, linking, allowed)
V/FA: Screen exposed for less than 1000 ms. Event not sent. time: 470
V/FA: Activity paused, time: 455509171
D/ViewRootImpl@560a619[dashboard]: MSG_WINDOW_FOCUS_CHANGED 0 1
D/InputMethodManager: prepareNavigationBarInfo() DecorView@ae2f610[dashboard]
getNavigationBarColor() -855310
E/libprocessgroup: set_timerslack_ns write failed: Operation not permitted
D/InputTransport: Input channel destroyed: 'ClientS', fd=245
I/Ads: Ad failed to load : 3
I/Ads: Ad failed to load : 3
D/ViewRootImpl@560a619[dashboard]: stopped(true) old=false
D/OpenGLRenderer: SurfaceChanged : 0x7e109da080 -> 0x0
W/m.mydrive: Accessing hidden method Lsun/misc/Unsafe;->getLong(Ljava/lang/Object;J)J (greylist,core-platform-api, linking, allowed)
W/m.mydrive: Accessing hidden method Lsun/misc/Unsafe;->getObject(Ljava/lang/Object;J)Ljava/lang/Object; (greylist, linking, allowed)
Jayce
  • 781
  • 3
  • 16
  • 35
  • issue resolved? i'm still facing problem, any solution? – NKR Mar 19 '20 at 01:54
  • @NKR still having the issue, what I did is have the app go to a new activity, switch to night/day mode and then put a 1 second delay to restart the previous activity after it is switched. Still not sure why it closes out the app when it recreates it, but that was the only way I could get it to keep the app open. Please though if you find another solution let me know. – Jayce Mar 19 '20 at 15:27
  • Are you using "Theme.AppCompat.DayNight" in styles? – NKR Mar 20 '20 at 16:26
  • 1
    @NKR yes, what is happening is that it has to recreate the activity to set the day/night mode and at that point is when it closes out the app. My work around above is okay, but it does make it look like the app is glitching because of the screen flashes. But still I don't know why it closes out the app itself if I don't use the work around. – Jayce Mar 20 '20 at 18:25
  • 3
    I solved this issue, i was calling finish() in onDestroy(). It was stoping from recreating activity. please check if are doing similar mistake. – NKR Mar 21 '20 at 02:36
  • 2
    @NKR thanks! I was calling System.exit(0) in onDestroy() and removing it solved this problem with night mode. – bytesculptor Jun 03 '20 at 08:36

0 Answers0