0
我正在处理联系人的android应用程序。代码在Android 2.1中不起作用
我在android 1.6中使用了下面的代码,它工作正常。
public static Uri getProfilepicture(Activity activity, String address)
{
Uri personUri = Uri.withAppendedPath(Phones.CONTENT_FILTER_URL, address);
Cursor phoneCursor = activity.getContentResolver().query(personUri,PHONE_PROJECTION, null, null, null);
if (phoneCursor.moveToFirst())
{
int indexPersonId = phoneCursor.getColumnIndex(Phones.PERSON_ID);
long personId = phoneCursor.getLong(indexPersonId);
phoneCursor.close();
Uri uri = ContentUris.withAppendedId(People.CONTENT_URI, personId);
return uri;
}
return null;
}
并获得照片的位图一样
Bitmap bm = People.loadContactPhoto(activity,getProfilepicture(activity, ConNum, R.drawable.artist, null);
任何一个可以建议为Android 2.1的代码吗?
People'此课程已弃用。 请参阅ContactsContract' – Selvin
感谢评论selvin。我知道我必须使用ContactsContract。在api 2.1我试着用它,但没有得到输出。如果你有任何工作的例子,请提供给我。 – milind
@milind我认为[这里](http://mobile.tutsplus.com/tutorials/android/android-essentials-using-the-contact-picker/)是使用ContactsContract ....的罕见例子。您可能已经看到。 – Hanry