English 中文(简体)
在“联系人”中添加数字在模拟器上有效,但在设备上无效
原标题:Adding a number into Contacts works on emulator but not on device

我已经编写了代码,在使用应用程序时在联系人簿中添加一个号码。

    ContentResolver cr = getContentResolver();
    Uri phoneUri = null;
    ContentValues values = new ContentValues();
    values.put(People.NAME, "stack");

    Uri uri = getContentResolver().insert(People.CONTENT_URI, values);
    phoneUri = Uri.withAppendedPath(uri, People.Phones.CONTENT_DIRECTORY);
    values.clear();
    values.put(People.Phones.TYPE, People.Phones.TYPE_MOBILE);
    values.put(People.Phones.NUMBER, "9879958170");
    getContentResolver().insert(phoneUri, values);

甚至在.manifest文件中添加了权限。

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

这是在模拟器上工作,添加了联系人,但。。当我将此应用程序放入设备时。。。。没有与名称堆栈联系。。。

有人能帮我吗?如果我做错了什么,请告诉我。

提前感谢:)

问题回答

你有什么电话?一些手机(例如三星)安装了一个经过修改的联系人应用程序,也许这就是原因。

你的手机运行的是什么版本的android?您在这里使用的是旧联系人API,如果您的手机运行的是Eclair或更好的,尽管这些API调用在技术上应该仍然有效,但不推荐使用。尤其是当我们谈论制造商定制的手机应用程序时,结果可能有点不可预测。

此外,有时如果您不将联系人添加到“我的联系人”系统组,则该联系人将不会出现在联系人应用程序中。并非每个联系人应用程序都是如此,但我在少数情况下看到过这种情况。

请提供更多信息,以便我们能够正确回答您的问题。(手机型号、运行的android版本等)





相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签