Android SecurityException on PDF Send Intent - android

I'm getting the following exception during an ACTION_SEND intent with a data type application/pdf:
java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.SEND typ=application/pdf flg=0x3080000 cmp=com.adobe.reader/.ARSendForSignature (has extras) }
This brings up a dialog to choose the desired application to receive the PDF. I believe the SecurityException is being thrown when a user chooses Adobe Reader from the list, although it appears to be opening specifically the ARSendForSignature activity.
Any ideas?

You are encountering a bug in the Adobe Reader app, or a bug in Android, depending upon your perspective.
The Adobe Reader ARSendForSignature activity supports the ACTION_SEND <intent-filter>, but they explicitly have android:exported="false", which denies anyone but them the ability to start that activity.
Either:
Adobe Reader should not have that <intent-filter>, or
Adobe Reader should not have marked it as not exported, or
The Android chooser should filter out non-exported activities
Long-term, the answer should be #3 -- I'll work on reproducing this problem and will file an issue, assuming there isn't already one. Short-term, Adobe can fix this faster than we can fix a couple hundred million devices. :-)

Related

Permission Denial when using ContentResolver

On Android 10,
I am trying to get data from external apps (like file managers, google photo etc) into my app using this guide -
https://developer.android.com/training/sharing/receive
After receiving the intent in my app, I am trying to open an input stream:
InputStream inputStream = new BufferedInputStream(CGlobals.context.getContentResolver().openInputStream(receivedURI));
It works initially from the Activity specified in the manifest, and even after.
However, I get a Permission Denial error in logcat-
Permission Denial: reading com.google.android.libraries.storage.storagelib.FileProvider uri content://com.google.android.apps.nbu.files.provider/2/721 from pid=19038, uid=10264 requires the provider be exported, or grantUriPermission()
when I am trying to get the input stream from other activities or threads in my app.
After trying for some time, I managed to find that this permission problem appears after I finish the initial activity.
What I can guess from this is, the Android system is granting this permission only as long as the initial activity is not finished.
If what I discovered is true, is this normal or a bug?
Thank you very much.

Opening link using Intent.ACTION_VIEW caused android.content.ActivityNotFoundException on certain device(s)

Recently I started getting android.content.ActivityNotFoundException: for my app logged on Google Play Console. Codes causing this exception are :
private void openLink(String url) {
Uri uri = Uri.parse(url);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
}
Now the exception is rarely happened, it works fine on most of devices, and the url is 100% valid (a link to https://mathsolver.microsoft.com/).
My question is what caused them and what is the best way to handle them.
Is a simple try catch enough or there is way so that user that catch this exception can still open the url from their phone?
Whenever you are starting an activity that is from another app — such as a Web browser — you have to take into account that the user might not have access to such an app. Even something as common as a Web browser might be restricted on some devices (e.g., devices used by children).
As such, you need to wrap such startActivity() calls in a try/catch block and deal with ActivityNotFoundException. Exactly how you deal with it will be up to your app, but you will need to explain to the user that you are unable to start the desired app for some reason.

What is a reliable way to open the Gallery?

The following code works most of the time:
intent = new Intent(Intent.ACTION_VIEW, Uri.parse("content://media/internal/images/media"));
startActivity(intent);
It throws the following exception sometimes (reported by error log from users):
android.content.ActivityNotFoundException: No Activity found to handle Intent {
act=android.intent.action.VIEW
dat=content://media/internal/images/media }
Stack trace:
android.content.ActivityNotFoundException: No Activity found to handle
Intent { act=android.intent.action.VIEW
dat=content://media/internal/images/media } at
android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1899)
at
android.app.Instrumentation.execStartActivity(Instrumentation.java:1589)
at android.app.Activity.startActivityForResult(Activity.java:4228)
at android.support.v4.app.k.startActivityForResult(SourceFile:50) at
android.support.v4.app.p.startActivityForResult(SourceFile:79) at
android.app.Activity.startActivityForResult(Activity.java:4187) at
android.support.v4.app.p.startActivityForResult(SourceFile:859) at
android.app.Activity.startActivity(Activity.java:4515) at
android.app.Activity.startActivity(Activity.java:4483)
I am wondering if some users' Android devices do not have Gallery.
I am wondering if some users' Android devices do not have Gallery.
There is no requirement for any Android device to have any exported activity that supports that particular Intent structure (ACTION_VIEW for whatever MIME type is tied to that Uri, plus a content scheme).
Beyond that, there is no single app named "Gallery". Out of ~2 billion devices and ~10,000 device models, there may be hundreds of apps that serve this general role, and a device might not have any such app.
What is a reliable way to open Gallery on Android?
See CATEGORY_APP_GALLERY, and be sure to handle the case where there is no matching activity.

Android bluetooth permission denial (although I use permissions)

To cut the story short. My logcat says:
java.lang.SecurityException: Permission Denial: starting Intent {
act=android.bluetooth.adapter.action.REQUEST_DISCOVERABLE
cmp=com.android.settings/.bluetooth.RequestPermissionActivity (has
extras) }
While I'm trying to execute:
Intent discoverIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
discoverIntent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 600);
startActivity(discoverIntent);
I have included all required permissions in the manifest. Moreover, some time ago I have written another application using bluetooth, which includes exactly this code (and I'm using the same there permissions). In that app everything works properly, here I get this exception while executing startingActivity(discoverIntent).
Do you have any ideas what's going on?
ANSWER ANSWER ANSWER
Maybe it sounds silly, but after restarting(sic!) my mobile phone, everything works perfect and I don't get any exceptions. If you have problem like this, try this simple solution.

Handle Intent VIEW typ=audio/mpeg

So idea is i am opening a file using apps that are already pre-installed on the device.
Here is my code
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setData(fileUri);
intent.setType(mimeType);
startActivity(intent);
And my error message is
08-25 12:50:32.900: E/AndroidRuntime(19555): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW typ=audio/mpeg }
Any ideas how to approach this? I read about intent filters, but the guy from here told me that if I am going to use other apps to open my files then I don't need to specify any filters, is it true?
P.S. for some reason it opens PDF files just fine, and JPG and TXT
Thanks
Dennis xx
Any ideas how to approach this?
Install an app on your phone that has an activity that handles this MIME type. Not every possible MIME type will be handled by the apps already on your device.
If you think that such-and-so app on your device ought to be able to handle this, use AppXplore to examine its manifest and see where you are going wrong (e.g., fileUri is using an unsupported scheme).
Check the supported media formats here. Make sure you are using one of those.

Categories

Resources