views:

147

answers:

2

Hello all, I have am wrighting an android app and as a part of the app I would like the user to be able to see, select,and modify the user contacts. My main activity extends the TabActivity for usability reasons(from the users side). So in a tab i would like to show user contacts i have done that with this code: mTabHost.addTab(mTabHost.newTabSpec("tab_test2").setIndicator("Contacts").setContent(new Intent(Intent.ACTION_PICK, People.CONTENT_URI))); that uses the default phone contact activity. my android manifest is: `

<uses-permission android:name="android.permission.READ_CONTACTS"/>
<uses-permission android:name="android.permission.READ_OWNER_DATA"/>

<application android:icon="@drawable/icon" android:theme="@android:style/Theme.NoTitleBar">

    <activity android:name=".WaveCally"
              android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity android:name=".streamer"
              android:label="@string/stream">
    </activity>



</application>
<uses-sdk android:minSdkVersion="4" />

` but i keep getting a security exception in my log and the activity crashes. any ideas? Also as I mentioned I would like to modify the contacts (mostly add some extra fields), to do that I have to get the contantprovider and in every contact add the extra fields? would those extra fields be available if i then pick a contact from the above mentioned activity? thanks in advanced maxsap

+1  A: 

You need to declare in the application Manifest that your application is going to access the Contacts. (android.permission.READ_CONTACTS)

This is what you need to do:

http://developer.android.com/guide/topics/manifest/uses-permission-element.html

Basically, add the following line in your app manifest (right after opening the manifest tag):

<uses-permission android:name="android.permission.READ_CONTACTS" />
ruibm
I have posted my manifest but for some reason the manifest tag is not shown. I have that permission but still get the exception that's why I posted in here because it seems strange. this is a copy from my manifest:<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.WaveCally" android:versionCode="1" android:versionName="1.0"> <uses-permission android:name="android.permission.READ_CONTACTS" /> <uses-permission android:name="android.permission.READ_OWNER_DATA"/>
maxsap
A: 

I'm trying to do the same thing and am running into the same problem. The checked answer doesn't solve the problem for me either (I already had the permissions). Is this just not possible?

dhaag23