Reputation: 1
I am using the isPrintServiceEnabled
new API of the PrintManager
class to retrieve the getPrintServiceState
of Android version 13 and above. After implementation, we encounter a java.lang.SecurityException: Permission denial
, indicating that we must have one of the following permissions: [android.permission.WRITE_SECURE_SETTINGS]. Steps to reproduce:
Here the sample code
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { PrintManager printManager = (PrintManager) context.getSystemService(Context.PRINT_SERVICE); ComponentName serviceComponent = new ComponentName(serviceName, PrintApplication.class.getName()); boolean isServiceAvailable = printManager.isPrintServiceEnabled(serviceComponent); if (isServiceAvailable) { return "enable"; } else { return "disable"; } }
Upvotes: 0
Views: 25