java.lang.SecurityException: Permission Denial: starting Intent - open settings screen - android

I want to open settings screen from my app.
I have made app exported = true in Manifest
Besides that I made sure that I pick correct configuration app while running
from this post -> Android - java.lang.SecurityException: Permission Denial: starting Intent
But still got this error
java.lang.SecurityException: Permission Denial: starting Intent { cmp=com.android.settings/.SubSettings } from ProcessRecord{a973751 21451:com.myapp.android.main/u0a157} (pid=21451, uid=10157) not exported from uid 1000
My code of launching the activity is
val intentTwo = Intent()
intentTwo.setClassName("com.android.settings",
"com.android.settings.SubSettings")
startActivity(intentTwo)
I have also tried this one
val intentOne = Intent()
intentOne.setComponent(ComponentName("com.android.settings",
"com.android.settings.SubSettings"))
startActivity(intentOne)
Any ideas on that?

SubSettings is not exported from the Settings app, at least for AOSP and Android 13. For any device configured this way, you cannot start this activity.
Also, please bear in mind that the system Settings app frequently gets modified by device manufacturers. As a result, there is no requirement for any device to even have SubSettings, let alone have it available to be started by external apps.
And, note that SubSettings does not seem to do much.

Related

Android 10 - file provider - permission denial

I'm facing a weird issue trying to provide a file in Android 10. My code works fine in Android 9 and 11 but in Android 10 only works 50% of the times. There are no difference on the system status when it works and when it doesn't.
The intent:
val intent = Intent(Intent.ACTION_VIEW).apply {
setDataAndType(file, UpdateHelper.APK_TYPE)
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
}
If I grant the permission explicitly, it always work. So my question is not how to fix it, but if there are any explanation for it that I'm missing. In my understanding granting the permission in the intent is the preferred way of doing it.
context?.grantUriPermission(packageName, file, Intent.FLAG_GRANT_READ_URI_PERMISSION)
Reviewing the documentation, it seems to be a race condition.
Permissions granted in an Intent remain in effect while the stack of the receiving Activity is active. When the stack finishes, the permissions are automatically removed.
For some reason this does not affect Android 9 and 11. But in Android 10 does.
The reason for my app to be finished is that I'm using this to pass a new apk to the packageInstaller in order to update the app.

Anyone knows where is "start in background" permission in MIUI 11?

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 . . .

java.lang.SecurityException: Permission Denial: starting Intent { flg=0x800000 cmp=com.android.systemui/.recents.RecentsActivity

I'm trying to open recent apps but I have a permission problem.
This feature works on Android 4, but seemingly from 6/7 is displaying the following error:
java.lang.SecurityException: Permission Denial: starting Intent { flg=0x800000 cmp=com.android.systemui/.recents.RecentsActivity }
val intent = Intent()
intent.component = ComponentName("com.android.systemui", "com.android.systemui.recents.RecentsActivity")
if (null != intent.resolveActivityInfo(context.packageManager, 0)) {
startActivity(intent)
}
Looks like its because new permissions system in android 6
Every Android app runs in a limited-access sandbox. If an app needs to
use resources or information outside of its own sandbox, the app has
to request the appropriate permission. You declare that your app needs
a permission by listing the permission in the app manifest and then
requesting that the user approve each permission at runtime (on
Android 6.0 and higher).
If your app needs a dangerous permission, you must check whether you
have that permission every time you perform an operation that requires
that permission. Beginning with Android 6.0 (API level 23), users can
revoke permissions from any app at any time, even if the app targets a
lower API level. So even if the app used the camera yesterday, it
can't assume it still has that permission today
check the documentation for more informations

Screenshot Notification requiring permission when clicked, but not when using Notification Share action

This looks like a bug (in Marshmallow) but, regardless, it needs to be worked around anyway.
Nexus 6P (6.0.1). Two scenarios:
take a screenshot / click on the notification's Share action / share to your app
An ACTION_SEND intent is delivered to the app and the app is (seemingly) granted permission to grab the image (which is specified in mClipData, not mData)
take a screenshot / click on the notification itself / share to your app
An ACTION_VIEW intent is delivered to the app, but the app does not have permission (unless already granted READ_EXTERNAL_STORAGE) because attempting to grab the image (which is specified in mData, not mClipData) gives:
Permission Denial: reading com.android.providers.media.MediaProvider uri content://media/external/images/media/1234 from pid=12345, uid=23456 requires android.permission.READ_EXTERNAL_STORAGE, or grantUriPermission()
Is there a way to work around this issue without resorting to the app itself requesting READ_EXTERNAL_STORAGE permission?
Yes if you open the image from the activity, not from the source/directory file. Or if you want to open from the source you need to add the READ_EXTERNAL_STORAGE to the android manifest.

Start Activity From Wallpaper Service (not preference related...)

I have a live Wallpaper. This live wallpaper has a settings page implemented from PreferenceActivity. Everything works as expected. So far, so good.
From my Wallpaper Settings page..I want to start another activity (a details activity...with info, bitmaps, links, etc...). When I start this activity I get a security exception error:
java.lang.SecurityException: Permission Denial: starting Intent {... } from ProcessRecord ... requires android.permission.BIND_WALLPAPER
The manifest has the required permission. I've tried putting this permission everywhere .. even in multiple locations (not just in the service tag in the manifest). I'm starting the Activity from the wallpaper settings page with a new intent, then calling startActivity.
Does anyone know why I'm getting the permission denial even when the permission is included? Can someone tell me how to start the activity correctly without getting a force close?
Much appreciated.

Categories

Resources