Android Question Turn off dark mode, or some other screen color issue [solved]

Didier9

Well-Known Member
Licensed User
Longtime User
Apparently my old apps turn ugly when the new dark mode of Android 10 is enabled (actually when I set the targetSDK to 26...)
Until I have the time (and knowledge) how to fix this problem properly, is there a way to prevent an app from using the dark theme?
 

Didier9

Well-Known Member
Licensed User
Longtime User
Thank you, I will try tonight.
Just a quick note before heading out, this is the manifest:
B4X:
AddManifestText(
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="21"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
'End of default text.
SetActivityAttribute(main, android:windowSoftInputMode, adjustResize|stateHidden)
AddManifestText(
<uses-permission
  android:name="android.permission.WRITE_EXTERNAL_STORAGE"
  android:maxSdkVersion="26" />
)
The problem shows up after I change the targetSdkVersion from 21 to 26
I have tried on both Android 9 and Android 10 and both do it, maybe it's not the dark theme?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
AddManifestText(
<uses-permission
android:name=
"android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="26" />
)
This is a mistake. Watch the runtime permissions video tutorial.

You are also missing the theme setting:
B4X:
CreateResourceFromFile(Macro, Themes.DarkTheme)
Or LightTheme.

The issue you encounter is not related to dark mode.
Post a screenshot.
 
Upvote 0

Didier9

Well-Known Member
Licensed User
Longtime User
Ok, this is an older project (started from an older example) and it has not been updated for the current permission protocol or theme setting. There may have been other issues as well. I will post a screen shot tonight.
 
Upvote 0

Shelby

Well-Known Member
Licensed User
Longtime User
I just noticed that your manifest shows that your minSdkVersion is 21 and the maximum is also 21. My minimums (which I think are default) are 5. I just wanted to point that out, although this could be a common usage that I'm not aware of.
 
Upvote 0

Didier9

Well-Known Member
Licensed User
Longtime User
Not sure why I set the min to 21, must have been an experiment. Most my other apps have 5, I still have a couple of tablets running Android 4.0.4... I changed it back to 5 to check it on an old tablet...

I have uploaded two sets of screenshots for two activities of my app, one set with targetSdkVersion=21 and one set with targetSdkVersion=26
These screen shots were taken on a Moto-X4 running Android 9. They look the same on the Pixel 2XL (Android 10)
 

Attachments

  • Main 21.png
    55.5 KB · Views: 284
  • Main 26.png
    53.1 KB · Views: 284
  • Scanner 21.png
    59.4 KB · Views: 288
  • Scanner 26.png
    52.6 KB · Views: 258
Upvote 0

Didier9

Well-Known Member
Licensed User
Longtime User
I changed the targetSdkVersion from 21 to 26 one by one and the change takes place at 24.
 
Upvote 0

Didier9

Well-Known Member
Licensed User
Longtime User
You are also missing the theme setting:
B4X:
CreateResourceFromFile(Macro, Themes.DarkTheme)
Or LightTheme.

I put this statement in the manifest and it cleared the problem. Now using targetSdkVersion=28

Thank you!
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…