I've problem when I want to read com.android.email.provider to
get email accounts.
Here is my code to retrieve the account :
Cursor c = null;
Uri CONTENT_URI = Uri.parse("content://com.android.email.provider/account");
String RECORD_ID = "_id";
String[] ID_PROJECTION = new String[] {RECORD_ID };
c = getContentResolver().query(CONTENT_URI,ID_PROJECTION,null, null, null);
I got a security exception:
java.lang.SecurityException: Permission Denial: reading com.android.email.provider.EmailProvider uri content://com.android.email.provider/account from pid=278, uid=10003 requires com.android.email.permission.ACCESS_PROVIDER
I want to know the account is created or not in some other app. Is there any other way to resolve this so that I can read from the provider.
I have also tried adding the permission in manifest:
<uses-permission android:name="com.android.email.permission.ACCESS_PROVIDER"/>
That didn't help.
Any solution would be greatly appreciated.
Thanks in advance
I'm afraid, it's impossible. See, here http://androidbridge.blogspot.com/2011/03/reading-emails-in-android.html
Related
I am a newbie. I try to get data(content, title ....) of memo app on Samsung phone. I used to "content://com.samsung.android.memo". My app is crashed and show message
java.lang.SecurityException: Permission Denial: opening provider com.samsung.android.app.memo.model.provider.memo.MemoProvider from ProcessRecord{9d45db 22489:com.example.kenshin.internetsamsung/u0a199} (pid=22489, uid=10199) requires com.samsung.android.memo.READ or com.samsung.android.memo.WRITE
After I add uses-permission on AndroidManifest.xml. but it still crashed. Please give me a advice. Thanks
"uses-permission android:name="com.samsung.android.memo.WRITE" and
"uses-permission android:name="com.samsung.android.memo.READ"
final Uri uri = Uri.parse("content://com.samsung.android.memo");
final Cursor c = getContentResolver().query(uri, null, null, null, null);
I am trying to implement signup activity in android using phone number as done by whatsapp and many other applications these days. But i also need to know the name of the user but without prompting the user to enter it himself/herself. is it possible? how does whatsApp manages to do it?
Looking for any suggestions possible here. Thanks.
You can use ContactsContract.Profile
String name = "";
Cursor c = getApplication().getContentResolver().query(ContactsContract.Profile.CONTENT_URI, null, null, null, null);
if(c.moveToFirst()) {
name = c.getString(c.getColumnIndex("display_name"));
c.close();
}
You need permissions too
<uses-permission android:name="android.permission.READ_PROFILE"/>
<uses-permission android:name="android.permission.READ_CONTACTS"/>
Read this Get Owner Name of an Android Device
I'm trying to read my gmail in Android like:
Cursor cur = cr.query(Uri.parse("content://gmail-ls/conversations/xxxxx#gmail.com"), null, null, null, null);
String[] columns = cur.getColumnNames();
and get a permission exception:
Permission Denial: opening provider com.google.android.gm.provider.MailProvider from ProcessRecord{416bc448 3111:com.t2.bigbrother/10070} (pid=3111, uid=10070) requires com.google.android.gm.permission.READ_GMAIL or com.google.android.gm.permission.WRITE_GMAIL
I've tried to add the permission but still get the exception. I'm on Ice Cream Sanwitch (Nexus)
Looks like you just can't do this anymore
See:
http://productforums.google.com/forum/#!msg/gmail/XD0C4sw9K7U/LpNXxFNnfgc%5B1-25%5D
com.google.android.gm.permission.READ_GMAIL will be the correct permission in this case.
i wrote the simple code
ContentResolver contentResolver = this.getContentResolver();
Uri uriSMSURI = Uri.parse("content://sms/");
// HERE I GET THE EXCEPTION
Cursor cur = getContentResolver().query(uriSMSURI, null, null, null, null);
int count = cur.getCount();
I get an exception about Permission Denial in the third line.
How can i get the Permission ? how can i access the messages ?
If you want to read SMS you have to specify the READ_SMS permission in your manifest like below...
<uses-permission android:name="android.permission.READ_SMS" />
The default behavior for Android is to exception an application that tries to access facets of the system that it has not explicitly requested access to, this is to protect the user from malicious software.
You need this line in your AndroidManifest.xml. It should be before the <application> tag.
<uses-permission android:name="android.permission.READ_SMS" />
i'm trying to access alarm provider to get all enabled alarm information.
so i wrote this :
public static final Uri CONTENT_URI =
Uri.parse("content://com.android.deskclock/alarm");
ContentResolver cr = getContentResolver();
Cursor c = null;
c = cr.query(
CONTENT_URI, ALARM_QUERY_COLUMNS,
null, null, DEFAULT_SORT_ORDER);
but it seemed to have the permission problem??
it always crashed QQ......could someone help me?
As #CommonsWare points out this only works on certain devices. Although with the other alarm URIs it was possible to read on most platforms. However in Honeycomb they have changed the access required and you can no longer use a content provider to get to the alarms.