Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

App crashes after switching night mode and mediaplayer stops

I have created an audio player app using Media Player, which streams a url from a JSON file. Everything works fine when switching UI mode (night mode to day mode & day mode to night mode), but it stops playing audio if I set datasource again then it crashes.

After Googling I found a solution, I did some changes in the manifest.xml file:

 <activity
        android:name=".MainActivity"
        android:configChanges="uiMode"
        android:launchMode="singleTask">

Now the media player is working properly, but I have to face another issue:

enter image description here

enter image description here

Some text color is matched with the background color and this issue comes up when I switch system UI mode to night mode after opening the app. If I open the app and scroll to the last item and then switch mode to night mode then this issue does not come up.

I am not sharing any code snippet here, as I have no idea which code I should share.

like image 944
Synonian_raj Avatar asked Sep 17 '25 12:09

Synonian_raj


1 Answers

I think this could solve your problem...

@Override
    protected void onNightModeChanged(int mode) {
        super.onNightModeChanged(mode);
    }
like image 189
J El Avatar answered Sep 19 '25 05:09

J El