English 中文(简体)
如何同时使用Android 1.x和2.x的联系人API?
原标题:How to use contacts API for Android 1.x and 2.x simultaneously?
  • 时间:2010-02-22 16:25:28
  •  标签:
  • android

我的问题是我需要在我的应用程序中实现通讯录,支持安卓1.5、1.6和2.x。

我使用旧的Contacts API完成了它,而不是ContactsContract,因为兼容1.x系列。但是在显示我的应用程序时,2.x上的联系人列表不完整。在某些设备上,它显示为空,而在某些设备上,它只显示设备中的某些联系人。

我知道在2.x系列上使用联系人API只会显示主要帐户联系人,但实际上不是这样的。看起来只有最近更新的联系人会显示,但实际上也不是这样的。

那么问题就是:如何在2.x和1.x的Android版本中正确实施联系人列表?

提前致謝

最佳回答

But when displaying my app on 2.x the contact list is not complete. In some devices it s shown as empty, and in some devices it only displays some of the contacts in the device.

正确。旧版联系人API仅访问仅存储在设备上的联系人,而不是通过从其他提供商同步获得的联系人。还存在一个bug,即在Android 2.0中甚至无法获得本地存储的联系人,尽管在Android 2.0.1中已经修复。

So the question is: How to correctly implement contact list for both 2.x and 1.x android version?

对于小版本的具体改动(例如,你刚刚需要正确的<代码>Uri),你只能使用“思考”,见

如果您的需求更加复杂,您可以通过创建一个接口(或抽象基类)和两个实现来利用条件类加载,分别针对每个API级别,然后只使用正确的实现。这在这个样本项目中演示了。

问题回答

暂无回答




相关问题
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 ...

热门标签