Question

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?

Was it helpful?

Solution

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" />
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top