Android securityException 和用户联系人

发布于 2024-08-16 03:01:53 字数 1228 浏览 4 评论 0 原文

我正在编写一个 Android 应用程序,作为应用程序的一部分,我希望用户能够查看、选择和修改用户联系人。出于可用性原因(从用户方面),我的主要活动扩展了 TabActivity。因此,在选项卡中,我想显示用户联系人,我已经使用以下代码完成了此操作: mTab​​Host.addTab(mTabHost.newTabSpec("tab_test2").setIndicator("Contacts").setContent(new Intent(Intent.ACTION_PICK) , People.CONTENT_URI))); 使用默认电话联系活动。我的 Android 清单是:`

<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" />

` 但我的日志中不断出现安全异常,并且活动崩溃。有什么想法吗? 另外,正如我提到的,我想修改联系人(主要是添加一些额外的字段),为此我必须获取 contantprovider 并在每个联系人中添加额外的字段?如果我从上述活动中选择联系人,这些额外字段是否可用?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

疯狂的代价 2024-08-23 03:01:53

您需要在应用程序清单中声明您的应用程序将访问联系人。 (android.permission.READ_CONTACTS

这是您需要做的:

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

基本上,在您的应用程序清单中添加以下行(在打开清单标签):

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

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" />
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文