Android: Java.Lang.Securityexception: Permission Denial: Start Intent

Android - java.lang.SecurityException: Permission Denial: starting Intent

You need to set android:exported="true" in your AndroidManifest.xml file where you declare this Activity:

<activity
android:name="com.example.lib.MainActivity"
android:label="LibMain"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" >
</action>
</intent-filter>
</activity>

Solve SecurityException: Permission Denial: starting Intent. What permission do I need?

You need to set android:exported="true" in your AndroidManifest.xml file

<activity
android:name="com.anurag.example.MainActivity"
android:label="Demo"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" >
</action>
</intent-filter>
</activity>

java.lang.SecurityException: Permission Denial: starting Intent sending an email on Android

gmail.setClassName("com.google.android.gm","com.google.andro‌​id.gm.ComposeActivit‌​yGmail");

This statement says that your app requires that the user use Gmail, and more specifically, that the user use some older version of Gmail. Hence, your code does not support:

  • Users of devices where Gmail simply is not installed (which may or may not be a possibility, depending upon your app distribution channels)

  • Users of devices where they do not have access to Gmail (e.g., secondary device users)

  • Users of devices where they have Gmail disabled, because they use some other email account (e.g., me)

  • Users of devices where they have Gmail available, but do not normally use it or would prefer not to use it for this particular situation

  • Users of devices with a current version of Gmail, as com.google.andro‌​id.gm.ComposeActivit‌​yGmail is no longer available for direct launch by third-party apps, such as yours

The latter point is what is leading to your exception.

So, delete that statement. Also:

  • plain/text is not a valid MIME type. Use text/plain. Or, better yet, get rid of gmail.setType("plain/text"); entirely, as you are not using EXTRA_TEXT or EXTRA_STREAM, and that is what the MIME type of an ACTION_SEND Intent is tied to.

  • Delete gmail.setData(Uri.parse("myEmail@email.com"));, as ACTION_SEND does not use the data facet of the Intent.

Permission Denial: starting intent (React Native)

I did a mistake that caused this error. I was doing this:

    <application
android:name=".MainApplication"
android:label="@string/app_name"
android:icon="@mipmap/checked"
android:allowBackup="false"
android:exported="true"
android:theme="@style/AppTheme">

<activity android:name=".MainActivity" />

But i had to do this:

    <application
android:name=".MainApplication"
android:label="@string/app_name"
android:icon="@mipmap/checked"
android:allowBackup="false"

android:theme="@style/AppTheme">

<activity android:name=".MainActivity"
android:exported="true"
/>

Basically i had to put android:exported="true" inside instead of >application> . Now the issue is solved.

java.lang.SecurityException: Permission Denial: starting Intent

the problem was because the permission
I have solved the problem by requesting permissions
in a different way

I used this one here

Android 6.0 multiple permissions

java.lang.SecurityException: Permission Denial: starting Intent on another application

Solved it by using:

Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setComponent(new ComponentName("com.aranoah.healthkart.plus","com.aranoah.healthkart.plus.pharmacy.search.autocomplete.SearchActivity"));
startActivity(intent);

Also, it requires you to add the correct class name. It all depends on how much you go through the manifest file of another app and perform the hit and trial method and hope that it might work out soon.

android: FATAL EXCEPTION: java.lang.SecurityException: Permission Denial: starting Intent { act=android.media.action.IMAGE_CAPTURE

If you are targeting API Level 23 or more, then you should force get permissions like below(contains several permissions, you can add or remove based on your requirement). Put this in a separate class:

public static List<String> checkAndRequestPermissions(Context context) {

int camera = ContextCompat.checkSelfPermission(context, android.Manifest.permission.CAMERA);
int readStorage = ContextCompat.checkSelfPermission(context, Manifest.permission.READ_EXTERNAL_STORAGE);
int writeStorage = ContextCompat.checkSelfPermission(context, android.Manifest.permission.WRITE_EXTERNAL_STORAGE);
int fineLoc = ContextCompat.checkSelfPermission(context, android.Manifest.permission.ACCESS_FINE_LOCATION);
int coarseLoc = ContextCompat.checkSelfPermission(context, android.Manifest.permission.ACCESS_COARSE_LOCATION);
List<String> listPermissionsNeeded = new ArrayList<>();

if (camera != PackageManager.PERMISSION_GRANTED) {
listPermissionsNeeded.add(android.Manifest.permission.CAMERA);
}
if (readStorage != PackageManager.PERMISSION_GRANTED) {
listPermissionsNeeded.add(android.Manifest.permission.READ_EXTERNAL_STORAGE);
}
if (writeStorage != PackageManager.PERMISSION_GRANTED) {
listPermissionsNeeded.add(android.Manifest.permission.WRITE_EXTERNAL_STORAGE);
}
if (fineLoc != PackageManager.PERMISSION_GRANTED) {
listPermissionsNeeded.add(android.Manifest.permission.ACCESS_FINE_LOCATION);
}
if (coarseLoc != PackageManager.PERMISSION_GRANTED) {
listPermissionsNeeded.add(android.Manifest.permission.ACCESS_COARSE_LOCATION);
}

return listPermissionsNeeded;
}

And in your activity:

public static final int REQUEST_ID_MULTIPLE_PERMISSIONS = 1;  // Declare this integer globally

Add this method(to retrieve permissions):

private boolean permissions(List<String> listPermissionsNeeded) {

if (!listPermissionsNeeded.isEmpty()) {
ActivityCompat.requestPermissions(this, listPermissionsNeeded.toArray
(new String[listPermissionsNeeded.size()]), REQUEST_ID_MULTIPLE_PERMISSIONS);
return false;
}
return true;
}

And force get permissions like this:

// In my case I've put the 'checkAndRequestPermissions' method in a separate class named 'PermissionUtils'
List<String> permissionList = PermissionUtils.checkAndRequestPermissions(this);

if (permissions(permissionList)) {

dispatchTakePictureIntent(); // call your camera instead of this method
}


Related Topics



Leave a reply



Submit