1

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?

BenMorel
  • 34,448
  • 50
  • 182
  • 322
maxsap
  • 2,971
  • 9
  • 44
  • 70

1 Answers1

2

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" />
rui
  • 11,015
  • 7
  • 46
  • 64
  • 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: – maxsap Dec 23 '09 at 16:47