Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Some Android phones not opening “About device” page in Settings?

Tags:

java

android

Some Android phones don't do anything when the the code below is ran. It's supposed to open the "About device" page in Settings.

For example, I know for a fact that it has no effect on the Huawei Y9 Prime 2019 running Android 10.

startActivity(new Intent(Settings.ACTION_DEVICE_INFO_SETTINGS));

What's the best way to safeguard against this issue when it occurs? (In my app, I open this page to ask the user to perform a specific action there)

like image 915
Panjeet Avatar asked May 23 '20 15:05

Panjeet


People also ask

Why is my settings not opening Android?

Clear Settings' Cache Step 2: Select App info to open a list of all apps installed on your device. Step 3: Scroll to the bottom of the screen and select Settings. Step 4: Next, select 'Storage & cache'. Step 5: Tap Clear cache.

Why can't I open settings on my phone?

Method 1: Restart your Android phone Most of the time, a simple restart will solve the problem for you. You can either switch off your phone and then turn it back on again, or you can simply tap on the restart option and wait for your phone to reboot.


1 Answers

Use PackageManager.resolveActivity() to check whether such an Activity exists. If that returns null, there is no activity that matches the Intent and you have to guide your customers to the settings in another way:

Intent intent = new Intent(Settings.ACTION_DEVICE_INFO_SETTINGS);
ResolveInfo resolveInfo = getPackageManager().resolveActivity(intent, 0);
if (resolveInfo == null) {
    // help customers by describing how to get to the device info settings

} else {
    startActivity(intent);
}
like image 57
Bram Stoker Avatar answered Oct 19 '22 12:10

Bram Stoker