Android Usage Access for Android 5 Samsung devices

后端 未结 1 831
臣服心动
臣服心动 2020-12-09 07:47

As you might know, since Android 5 was launched, accessing the recent tasks (usage stats) of your device requires the user to enable this feature manually (Settings->Securit

相关标签:
1条回答
  • 2020-12-09 08:26

    Sorry for the late reply, I hope you have found a good solution, but if not or for other people who have this problem,

    this bug seems to exist in some Samsung models, to avoid the crash of your app, maybe you can check if your intent can be handled

    PackageManager packageManager = getActivity().getPackageManager();
    
    if (intent.resolveActivity(packageManager) != null) {
        startActivity(intent);
    } else {
        Toast.makeText(getBaseContext(), "Please open settings, your model can't be forced 
                              to open it", Toast.LENGTH_LONG).show();
    }
    
    0 讨论(0)
提交回复
热议问题