MIUI 11/12 Theme Switch Results in LifeCycleException, ClassCastException

Ayush

Since MIUI 11/12 Use Its Own Custom Implementation of Dark Mode, using below code results in ClassCastException and Activity Life Cycle Exception, as DefaultNightMode and LocalNightMode is always Unspecified i.e. -100 instead of 0 or 1.

If anyone has built a workaround for Xiaomi Devices specially for MIUI 11/12. Please Help Me Out On this.

Code Used:

AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
this.recreate();

Error Caused:

2020-10-25 07:04:43.626 9167-9167/com.xxxx.xxxxxx E/ActivityInjector: get life cycle exception
    java.lang.ClassCastException: android.os.BinderProxy cannot be cast to android.app.servertransaction.ClientTransaction
Ayush

I solved it myself. After fiddling around with it for a week, I did it..

Here is how:

-- Instead of setting android:forceDarkAllowed="false" for each and every Activity.

-- Just goto values.xml and place this in your AppTheme

        <item name="android:forceDarkAllowed">false</item>

It will ask you to create a valuesv29.xml. Create it, and remove the forceDarkAllowed="false" from all activities.

Welcome. :)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

Push notifications with no sound on MIUI

From Dev

Hibernate Mapped Composite Key ManyToMany results in ClassCastException

From Dev

LifecycleException deploying Spring Boot WebSocket example into Tomcat

From Dev

How to access switch results of a case?

From Dev

AngularJS switch css theme on user selection

From Dev

switch theme in javascript

From Dev

Theme.AppCompat.Light.DarkActionBar results in no ActionBar showing

From Dev

Android app: Switch images based on theme from code

From Dev

Switch statement not displaying any results

From Dev

Switch theme in an existing Jekyll installation

From Dev

Defining a block in a switch statement results in a compiler error

From Dev

How can we switch the theme in Ionic App from Lighter version to darker version ?

From Dev

Switch Statement returns incorrect results

From Dev

Customize the search results page in a Wordpress Genesis child theme

From Dev

Saving data from Spark to Cassandra results in java.lang.ClassCastException

From Dev

Theme is not set by pressing Switch. App doesn't crash

From Dev

Dual Monitors switch theme/wallpaper

From Dev

Is there any fast switch between light mode and dark mode (light/dark theme) in 16.04?

From Dev

Hibernate Mapped Composite Key ManyToMany results in ClassCastException

From Dev

LifecycleException deploying Spring Boot WebSocket example into Tomcat

From Dev

Why does the query not return results after I switch the class it queries?

From Dev

PHP switch returning inconsistent results

From Dev

How to access switch results of a case?

From Dev

Tomcat 7 WAR deploy LifecycleException

From Dev

If and Switch same task, different results?

From Dev

Customize the search results page in a Wordpress Genesis child theme

From Dev

Results from search not shown in iframe (using switch statement)

From Dev

Tell if device is running a MIUI software

From Dev

While loop within switch case - Grouping results

Related Related

  1. 1

    Push notifications with no sound on MIUI

  2. 2

    Hibernate Mapped Composite Key ManyToMany results in ClassCastException

  3. 3

    LifecycleException deploying Spring Boot WebSocket example into Tomcat

  4. 4

    How to access switch results of a case?

  5. 5

    AngularJS switch css theme on user selection

  6. 6

    switch theme in javascript

  7. 7

    Theme.AppCompat.Light.DarkActionBar results in no ActionBar showing

  8. 8

    Android app: Switch images based on theme from code

  9. 9

    Switch statement not displaying any results

  10. 10

    Switch theme in an existing Jekyll installation

  11. 11

    Defining a block in a switch statement results in a compiler error

  12. 12

    How can we switch the theme in Ionic App from Lighter version to darker version ?

  13. 13

    Switch Statement returns incorrect results

  14. 14

    Customize the search results page in a Wordpress Genesis child theme

  15. 15

    Saving data from Spark to Cassandra results in java.lang.ClassCastException

  16. 16

    Theme is not set by pressing Switch. App doesn't crash

  17. 17

    Dual Monitors switch theme/wallpaper

  18. 18

    Is there any fast switch between light mode and dark mode (light/dark theme) in 16.04?

  19. 19

    Hibernate Mapped Composite Key ManyToMany results in ClassCastException

  20. 20

    LifecycleException deploying Spring Boot WebSocket example into Tomcat

  21. 21

    Why does the query not return results after I switch the class it queries?

  22. 22

    PHP switch returning inconsistent results

  23. 23

    How to access switch results of a case?

  24. 24

    Tomcat 7 WAR deploy LifecycleException

  25. 25

    If and Switch same task, different results?

  26. 26

    Customize the search results page in a Wordpress Genesis child theme

  27. 27

    Results from search not shown in iframe (using switch statement)

  28. 28

    Tell if device is running a MIUI software

  29. 29

    While loop within switch case - Grouping results

HotTag

Archive