I got this error when I try to launch the details screen.
IActivityManagerProxy : Instant app: com.foo.bar crashed: java.lang.SecurityException: Not allowed to start activity Intent { act=android.settings.APPLICATION_DETAILS_SETTINGS dat=package:com.foo.bar }
Is there any work around to launch details on instant app?
You're trying to access settings. This is intentionally not available to instant apps for security reasons.
A workaround would be to ask the user to manually go to the settings in case your app is running in the instant app context.
Related
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.
Step 1: Open my app
Step 2: Open system settings(My app is still alive, not killed)
Step 3: Choose a permission of my app(e.g. camera or location), which state is allow and turn it to deny
Step 4: Open my app
My app dead in Step3, and in Step4 it start a new thread. It also happened on other apps. I try these on android 10 and android 12 emulator.
Other apps I' ve tried on emulator: WeChat, Google Photos, Chrome. For most kinds of permission they dead, and for some permissions they still alive. (My WeChat dead when denied camera permission, but for "Draw over other apps" permission, it did not)
Why did the thread die? There is no useful log in the dead thread. The new thread says: Redefining intrinsic method java.lang.Thread java.lang.Thread.currentThread(). This may cause the unexpected use of the original definition of java.lang.Thread java.lang.Thread.currentThread()in methods that have already been compiled.
When your app is alive. if you revoke permission from the settings page. The app process will be recreated. it will go to the exact screen where you are before the app gets killed. but viewmodel and all objects would be null at this point.
Refer:
Crash when disable permission and go back to the app
I have a scenario to do a mobile automation with the androd app. The issue here is, I am getting Permission denied error when launching through appium.
Appium forum suggested that, need to add the android: export= false parameter in their manifest.
My question is, Is there any workaround to launch without amending the manifest.
Sometimes apps have a specific activity that allows you to enter. It routes you to the main activity. Would be best if you could consult with the developers of the app to provide the activity name.
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);
}
I develop an app and support Android 6.0. When I reset app preferences in Settings -> Apps -> Reset app preferences, all permissions of my app are revoked and the app is not restarted. Failure to restart the app after revoking its permissions can cause many unexpected crashes.
How should I handle this case?
The app is restarted when I revoke its permissions manually (Settings -> Apps -> My app -> Permissions).
I can reproduce the problem. I have filed an issue in regards to it.
How should I handle this case?
Since this is a fairly low-probability event (how many users are ever going to find that option, let alone blow past the warning dialog and actually do it?), personally, I wouldn't worry about it too much.
Since there is no documented setOnPermissionChangeListener() or ACTION_DUDE_YOUR_PERMS_WUZ_WHACKED or anything to find out about the permission change, there is not a lot you can really do here. Having checkSelfPermission() calls as close as possible to calling the protected APIs will help reduce the window of time where you are at risk of a permission being revoked behind your back.