I'm not able to start activity in MIUI 11 redmi note 6 pro mobile, I am getting error as:
com.android.server.am.ExtraActivityManagerService: MIUILOG- Permission Denied Activity
I found some solution like turn on "start in background" permission. I can't find something like this with MIUI 11. Literally I have no idea about this issue. Thanks in advance.
I have a similar problem with starting activity from BroadcastReceiver when application is stopped.
1) You can find your app in the settings and allow permission "start in the background".
2) If you need to allow permission programmatically, try to open application settings
Xiaomi
This code will open applicatin permissions settings in which you should allow "start in the background"
Intent intent = new Intent("miui.intent.action.APP_PERM_EDITOR");
intent.setClassName("com.miui.securitycenter",
"com.miui.permcenter.permissions.PermissionsEditorActivity");
intent.putExtra("extra_pkgname", getPackageName());
startActivity(intent);
Devices without system wrappers
This code will open the applicatin settings in which you should open permissions and allow "start in the background" permission
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
Read more about android settings intents:
How to open application permission window in app settings programmatically
And you can also check the code from github to work with permissions in different system wrappers like flyme, miui, oppo etc:
https://github.com/zhaozepeng/FloatWindowPermission
Hope this helps you!
If you have other options for resolving this issue, I would appreciate a reply in the comments . . .
Related
what is the proper way to request accessibility permission on xiaomi/miui devices programmatically?
The code snippet below on all other devices takes you to the screen with the option to enable accessibility. But on Xiaomi devices it takes to a screen with the following options: "Volume Shortcut", "Accessibility Menu" and "Downloaded Services", and none of these options enable the accessibility system.
Intent intent = new Intent("android.settings.ACCESSIBILITY_SETTINGS");
startActivity(intent);
startActivityForResult(intent, 0);
Thaks a lot!
Yes I had same problem but when you click on 'download service' you can get to see all apps asking for accessibility permission.
I have created an app which lists the all applications available on my device.
Clicking on a specific app displays the permission associated with it.
I have done this using the package name of the specific app.
The Permissions are sorted with a switch button.
Switch checked shows the particular permission is granted and vice versa.
Upon changing the switch and clicking on Apply changes(Button residing at the bottom of the page)user should be able to change the permission of the application.
For this I have read an accessibility service would be a better option.
I have searched many things available and i have learnt that navigating through a particular application settings ---> permission screen and reading the window content available and using the button action of the accessibility service things can be done.
But the first and foremost thing is navigating to the settings --> Permission is quiet tricky.
As per this How to programmatically open the Permission Screen for a specific app on Android Marshmallow?
In stack overflow I have found answer suggesting the navigating through the permission is impossible but I have seen apps which directly takes you to the permission screen.
For example : Files go by google
Files Go
But I am unable to create an accessibility service which can read the settings ---> permissions of a particular app and change the permissions.
To open settings page
Intent intent = new Intent();
intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
Uri uri = Uri.fromParts("package", getPackageName(), null);
intent.setData(uri);
startActivity(intent);
iam trying to develop app similar to this app -
Permission Manager
Any help would be appreciated . Thanks in advance
Any doubts related to question i will respond immediately.please comment below .
please do not mark as closed or unclear what iam asking. Iam ready to explain if the question is not understandable.
I want to enable floating notification using Android Code.Normally users didn't know about the setting. so i need to enable this as default.
Bad news I'm afraid.
As you probably are aware, this requires the permission SYSTEM_ALERT_WINDOW.
Since Android M google has begun locking down this permission to reduce clutter. What is a little unusual about this permission is it requires the user to go to an actual settings screen The ordinary Android M permission flow does not work for this. To quote the API:
If the app targets API level 23 or higher, the app user must explicitly grant this permission to the app through a permission management screen
You use the Settings class to check if you already have the permission and when you don't, you need to explain and direct the user to the relevant settings screen via intent:
Intent i = new Intent();
i.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
i.addCategory(Intent.CATEGORY_DEFAULT);
i.setData(Uri.parse("package:" + context.getPackageName()));
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
i.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
context.startActivity(i);
This should only ever affect devices running 23+ as older devices should get the permission automatically, but don't rely on checking SDK_INT, rely instead on canDrawOverlays, as there are exceptions for some pre-marshmallow devices
I was also facing same issue and need to enable it from settings but after adding permission in manifest file it worked perfectly.
<uses-permission android:name="android.permission.ACCESS_NOTIFICATION_POLICY" />
Tested on version 9.
I struggled with that and found a way.
(In my case I'm using the OneSignal React-Native SDK)
The solution was to create a "category" (on the OneSignal console) that has the "urgent" importance :)
After that, when you send a push, you have to refer to the channel_id of this category.
Doc: https://documentation.onesignal.com/docs/android-notification-categories
I am building an android application where I am using some services. My services get close when application is close in some custom android OS like MI.
Then I figure out we have to push our application in white list of security autostart application.
I got some SOF link's where they are suggesting below answer.
String manufacturer = "xiaomi";
if(manufacturer.equalsIgnoreCase(android.os.Build.MANUFACTURER)) {
//this will open auto start screen where user can enable permission for your app
Intent intent = new Intent();
intent.setComponent(new ComponentName("com.miui.securitycenter", "com.miui.permcenter.autostart.AutoStartManagementActivity"));
startActivity(intent);
}
This above code used to send user to that particular page.
Now I have to check if my application is disable so I can send user to this page and if it is enable then move to other screen. Is there any way to check this?
There is no Android API to check if the the AutoStart is enabled or not. Though you can have your own logic in the App (may be you can use preference to set a Boolean for it) to check this. Also the above way to enabling the AutoStart might not work always. Please have a look here
i want to know that is there any way i can prevent my android app from killing from task manager. Whether it's any third party app, clears from ram manager or user clicks force stop. i just don't want kill my app from background, It should be running.
How to disable the "Force Stop" button
Short answer: Use the Device Administration API.
How do I demonstrate that it works?
Yes, back to your job. Use the API link provided above and the Api Demos included in Google's sample collection to figure out how to integrate this into your app.
Build the demo and run it on your device.
Choose API Demos->App->Device Admin->General->Enable admin.
Choose Activate once the Device Administration API prompts you with its enabling screen.
Exit the app and attempt to manage the app via your device's settings menu (specifics for this step varies by device).
When viewing the Api Demo's "app info" screen, you should see both Force Stop and Uninstall are disabled.
How do I do this in my own app?
Review DeviceAdminSample.java in the Api Demos app for inspiration. You will need the following:
The following code is what brings up the activation screen:
// Launch the activity to have the user enable our admin.
Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, mDeviceAdminSample);
intent.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION,
mActivity.getString(R.string.add_admin_extra_app_text));
startActivityForResult(intent, REQUEST_CODE_ENABLE_ADMIN);
However, there are a few other pieces you will need to get this to work:
A broadcast receiver that derives from DeviceAdminReceiver.
Entries in your manifest file that refer to the above broadcast receiver.
Permissions in your manifest for using the Device Administrator API.
An xml file stating what policies your app can access.
All of this can be found in the above links. Good luck with your client!
This might be a dirty way to do this. But it worked for me.
Just override onDestroy() method in service and start that service again.
#Override
public void onDestroy() {
Intent intent = new Intent(this,YourService.class);
startService(intent);
}