In our application we need to read attachments from email clients and upload it to server. For default android email client everything works fine,but for gmail application facing
java.lang.SecurityException: Permission Denial: opening provider com.google.android.gm.provider.MailProvider from ProcessRecord (pid=11298, uid=10068) requires com.google.android.gm.permission.READ_GMAIL or com.google.android.gm.permission.WRITE_GMAIL
Have even tried giving Gmail read write permissions but did not work.
Observations are
It is working fine for Nexus but for samsung devices 4.2 and 4.1,working fine initially if activity is created for first time,but if activity is in background throwing above said exceptions.
Trying to get attachment file name using below code.
Cursor cursor = getContentResolver().query(openIntent.getData(),
new String[] { MediaStore.MediaColumns.DISPLAY_NAME }, null,
null, null);
cursor.moveToFirst();
int nameIndex = cursor
.getColumnIndex(MediaStore.MediaColumns.DISPLAY_NAME);
if (nameIndex >= 0) {
NCUtil.clickedImageTitle = cursor.getString(nameIndex);
path = cursor.getString(nameIndex);
}
cursor.close();
My Manifest file
<activity
android:name="com.ncomputing.vspacemobile.NCMainActivity"
android:configChanges="orientation|keyboard|keyboardHidden|screenSize"
android:excludeFromRecents="true"
android:launchMode="singleTask"
android:screenOrientation="sensorPortait"
android:theme="@android:style/Theme.NoTitleBar"
android:windowSoftInputMode="adjustPan" >
<!-- For email attachments -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="application/pdf" />
<data android:mimeType="application/msword" />
<data android:mimeType="application/vnd.openxmlformats-officedocument.wordprocessingml.document" />
<data android:mimeType="application/vnd.ms-excel" />
<data android:mimeType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" />
<data android:mimeType="application/vnd.ms-powerpoint" />
<data android:mimeType="application/vnd.openxmlformats-officedocument.presentationml.presentation" />
<data android:mimeType="text/plain" />
<data android:mimeType="text/comma-separated-values" />
<data android:mimeType="application/rtf" />
</intent-filter>
</activity>
User permissions
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
Please let us know how can i make it work,i need the activity launch mode as singleTask and access the attachments.