0 votes
in Android by (150 points)
edited by

3 Answers

+1 vote
by (180 points)
To fix issues with your code not working on Android 12 and above, you will need to first identify the root cause of the problem. Here are some steps you can follow:

Check for error messages: Look for any error messages in the Android logs or in the Android Studio console. This will help you identify the specific problem that is causing your code to fail.

Review the changes in Android 12: Review the changes that have been made in Android 12 and check if any of them are affecting your code. This can include changes to app permissions, changes to the way apps access the network, or changes to the way the user interface is rendered.

Check for deprecated APIs: If you are using any deprecated APIs, they may not work properly on Android 12. Check the Android documentation to see if any of the APIs you are using have been deprecated or removed in Android 12.

Test on a device running Android 12: If possible, test your code on a device running Android 12 to see if you can reproduce the issue. This will help you identify any specific problems that are related to the new operating system.

Update your code: Once you have identified the specific problems with your code, update it to work properly with Android 12. This may involve updating your app permissions, changing the way your app accesses the network, or updating any deprecated APIs you are using.

Test again: Once you have updated your code, test it again on a device running Android 12 to ensure that everything is working as expected.

Remember, if you are still having trouble, you can always consult the Android documentation, forums, or seek help from a professional Android developer.
+1 vote
by (280 points)
Clearing the cache in Android Studio can help resolve some issues. Go to "File" > "Invalidate Caches/Restart" and select "Invalidate and Restart" to clear the cache.
+1 vote
by (160 points)

Android 12 has introduced changes to the way permissions are handled. If your app requires certain permissions to function properly, make sure that you have declared those permissions in your app manifest file and request them at runtime. In android 12, we don't have permissions like android.permission.MODIFY_PHONE_STATE or android.permission.BLUETOOTH_ELEVATED. Instead of that, we have to use android.permission.BLUETOOTH_CONNECT and make necessary changes in the code according to that.

For eg: to enable bluetooth

BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); if (!bluetoothAdapter.isEnabled()) { bluetoothAdapter.enable(); }

Welcome to Reubro Q&A, where you can ask questions and receive answers from other members of the community.
...