本文整理汇总了Java中android.provider.ContactsContract.Profile类的典型用法代码示例。如果您正苦于以下问题:Java Profile类的具体用法?Java Profile怎么用?Java Profile使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Profile类属于android.provider.ContactsContract包,在下文中一共展示了Profile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSelfiUri
import android.provider.ContactsContract.Profile; //导入依赖的package包/类
public static Uri getSelfiUri(Context context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
&& context.checkSelfPermission(Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED) {
return null;
}
String[] mProjection = new String[]{Profile._ID, Profile.PHOTO_URI};
Cursor mProfileCursor = context.getContentResolver().query(
Profile.CONTENT_URI, mProjection, null, null, null);
if (mProfileCursor == null || mProfileCursor.getCount() == 0) {
return null;
} else {
mProfileCursor.moveToFirst();
String uri = mProfileCursor.getString(1);
mProfileCursor.close();
if (uri == null) {
return null;
} else {
return Uri.parse(uri);
}
}
}
示例2: getSefliUri
import android.provider.ContactsContract.Profile; //导入依赖的package包/类
public static Uri getSefliUri(Context context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
&& context.checkSelfPermission(Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED) {
return null;
}
String[] mProjection = new String[] { Profile._ID, Profile.PHOTO_URI };
Cursor mProfileCursor = context.getContentResolver().query(
Profile.CONTENT_URI, mProjection, null, null, null);
if (mProfileCursor == null || mProfileCursor.getCount() == 0) {
return null;
} else {
mProfileCursor.moveToFirst();
String uri = mProfileCursor.getString(1);
mProfileCursor.close();
if (uri == null) {
return null;
} else {
return Uri.parse(uri);
}
}
}
示例3: getContactInfoForSelf
import android.provider.ContactsContract.Profile; //导入依赖的package包/类
/**
* @return a Contact containing the info for the profile.
*/
private Contact getContactInfoForSelf() {
Contact entry = new Contact(true);
entry.mContactMethodType = CONTACT_METHOD_TYPE_SELF;
if (Log.isLoggable(LogTag.CONTACT, Log.DEBUG)) {
log("getContactInfoForSelf");
}
Cursor cursor = mContext.getContentResolver().query(
Profile.CONTENT_URI, SELF_PROJECTION, null, null, null);
if (cursor == null) {
Log.w(TAG, "getContactInfoForSelf() returned NULL cursor!"
+ " contact uri used " + Profile.CONTENT_URI);
return entry;
}
try {
if (cursor.moveToFirst()) {
fillSelfContact(entry, cursor);
}
} finally {
cursor.close();
}
return entry;
}
示例4: getProfilePictureUri
import android.provider.ContactsContract.Profile; //导入依赖的package包/类
public static Uri getProfilePictureUri(Context context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && context.checkSelfPermission(Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED) {
return null;
}
final String[] projection = new String[]{Profile._ID, Profile.PHOTO_URI};
final Cursor cursor;
try {
cursor = context.getContentResolver().query(Profile.CONTENT_URI, projection, null, null, null);
} catch (SecurityException e) {
return null;
}
if (cursor == null) {
return null;
}
final String uri = cursor.moveToFirst() ? cursor.getString(1) : null;
cursor.close();
return uri == null ? null : Uri.parse(uri);
}
示例5: getProfilePictureUri
import android.provider.ContactsContract.Profile; //导入依赖的package包/类
public static Uri getProfilePictureUri(Context context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && context.checkSelfPermission(Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED) {
return null;
}
final String[] projection = new String[]{Profile._ID, Profile.PHOTO_URI};
final Cursor cursor;
try {
cursor = context.getContentResolver().query(Profile.CONTENT_URI, projection, null, null, null);
} catch (SecurityException e) {
return null;
}
if (cursor == null) {
return null;
}
final String uri = cursor.moveToFirst() ? cursor.getString(1) : null;
cursor.close();
return uri == null ? null : Uri.parse(uri);
}
示例6: getSefliUri
import android.provider.ContactsContract.Profile; //导入依赖的package包/类
public static Uri getSefliUri(Context context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
&& context.checkSelfPermission(Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED) {
return null;
}
String[] mProjection = new String[]{Profile._ID, Profile.PHOTO_URI};
Cursor mProfileCursor = context.getContentResolver().query(
Profile.CONTENT_URI, mProjection, null, null, null);
if (mProfileCursor == null || mProfileCursor.getCount() == 0) {
return null;
} else {
mProfileCursor.moveToFirst();
String uri = mProfileCursor.getString(1);
mProfileCursor.close();
if (uri == null) {
return null;
} else {
return Uri.parse(uri);
}
}
}
示例7: getSefliUri
import android.provider.ContactsContract.Profile; //导入依赖的package包/类
public static Uri getSefliUri(Context context) {
String[] mProjection = new String[] { Profile._ID, Profile.PHOTO_URI };
Cursor mProfileCursor = context.getContentResolver().query(
Profile.CONTENT_URI, mProjection, null, null, null);
if (mProfileCursor == null || mProfileCursor.getCount() == 0) {
return null;
} else {
mProfileCursor.moveToFirst();
String uri = mProfileCursor.getString(1);
mProfileCursor.close();
if (uri == null) {
return null;
} else {
return Uri.parse(uri);
}
}
}
示例8: getSefliUri
import android.provider.ContactsContract.Profile; //导入依赖的package包/类
public static Uri getSefliUri(Context context) {
String[] mProjection = new String[] { Profile._ID,
Profile.PHOTO_THUMBNAIL_URI };
Cursor mProfileCursor = context.getContentResolver().query(
Profile.CONTENT_URI, mProjection, null, null, null);
if (mProfileCursor.getCount() == 0) {
return null;
} else {
mProfileCursor.moveToFirst();
String uri = mProfileCursor.getString(1);
if (uri == null) {
return null;
} else {
return Uri.parse(uri);
}
}
}
示例9: updateAvatarView
import android.provider.ContactsContract.Profile; //导入依赖的package包/类
private void updateAvatarView(String addr, boolean isSelf) {
Drawable avatarDrawable;
if (isSelf || !TextUtils.isEmpty(addr)) {
Contact contact = isSelf ? Contact.getMe(false) : Contact.get(addr, false);
avatarDrawable = contact.getAvatar(mContext, sDefaultContactImage);
if (isSelf) {
mAvatar.assignContactUri(Profile.CONTENT_URI);
} else {
if (contact.existsInDatabase()) {
mAvatar.assignContactUri(contact.getUri());
} else {
mAvatar.assignContactFromPhone(contact.getNumber(), true);
}
}
} else {
avatarDrawable = sDefaultContactImage;
}
mAvatar.setImageDrawable(avatarDrawable);
}
示例10: loadAvatarData
import android.provider.ContactsContract.Profile; //导入依赖的package包/类
private byte[] loadAvatarData(Contact entry) {
byte [] data = null;
if ((!entry.mIsMe && entry.mPersonId == 0) || entry.mAvatar != null) {
return null;
}
if (Log.isLoggable(LogTag.CONTACT, Log.DEBUG)) {
log("loadAvatarData: name=" + entry.mName + ", number=" + entry.mNumber);
}
// If the contact is "me", then use my local profile photo. Otherwise, build a
// uri to get the avatar of the contact.
Uri contactUri = entry.mIsMe ?
Profile.CONTENT_URI :
ContentUris.withAppendedId(Contacts.CONTENT_URI, entry.mPersonId);
InputStream avatarDataStream = Contacts.openContactPhotoInputStream(
mContext.getContentResolver(),
contactUri, true);
try {
if (avatarDataStream != null) {
data = new byte[avatarDataStream.available()];
avatarDataStream.read(data, 0, data.length);
}
} catch (IOException ex) {
//
} finally {
try {
if (avatarDataStream != null) {
avatarDataStream.close();
}
} catch (IOException e) {
}
}
return data;
}
示例11: loadAvatarData
import android.provider.ContactsContract.Profile; //导入依赖的package包/类
private byte[] loadAvatarData(Contact entry) {
byte [] data = null;
if ((!entry.mIsMe && entry.mPersonId == 0) || entry.mAvatar != null) {
return null;
}
if (Log.isLoggable(LogTag.CONTACT, Log.DEBUG)) {
log("loadAvatarData: name=" + entry.mName + ", number=" + entry.mNumber);
}
// If the contact is "me", then use my local profile photo. Otherwise, build a
// uri to get the avatar of the contact.
Uri contactUri = entry.mIsMe ?
Profile.CONTENT_URI :
ContentUris.withAppendedId(Contacts.CONTENT_URI, entry.mPersonId);
InputStream avatarDataStream = Contacts.openContactPhotoInputStream(
mContext.getContentResolver(),
contactUri);
try {
if (avatarDataStream != null) {
data = new byte[avatarDataStream.available()];
avatarDataStream.read(data, 0, data.length);
}
} catch (IOException ex) {
//
} finally {
try {
if (avatarDataStream != null) {
avatarDataStream.close();
}
} catch (IOException e) {
}
}
return data;
}
示例12: findSelfInfo
import android.provider.ContactsContract.Profile; //导入依赖的package包/类
@Override
public CallerInfo findSelfInfo(Context ctxt) {
CallerInfo callerInfo = new CallerInfo();
String[] projection = new String[] {
Profile._ID,
Profile.DISPLAY_NAME,
Profile.PHOTO_ID,
Profile.PHOTO_URI
};
Cursor cursor = ctxt.getContentResolver().query(Profile.CONTENT_URI, projection, null, null, null);
if(cursor != null) {
try {
if(cursor.getCount() > 0) {
cursor.moveToFirst();
ContentValues cv = new ContentValues();
DatabaseUtils.cursorRowToContentValues(cursor, cv);
callerInfo.contactExists = true;
if(cv.containsKey(Profile.DISPLAY_NAME) ) {
callerInfo.name = cv.getAsString(Profile.DISPLAY_NAME);
}
if(cv.containsKey(Profile._ID) ) {
callerInfo.personId = cv.getAsLong(Profile._ID);
callerInfo.contactContentUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, callerInfo.personId);
}
if(cv.containsKey(Profile.PHOTO_ID)) {
Long photoId = cv.getAsLong(Profile.PHOTO_ID);
if(photoId != null) {
callerInfo.photoId = photoId;
}
}
if(cv.containsKey(Profile.PHOTO_URI)) {
String photoUri = cv.getAsString(Profile.PHOTO_URI);
if(!TextUtils.isEmpty(photoUri)) {
callerInfo.photoUri = Uri.parse(photoUri);
}
}
if(callerInfo.name != null && callerInfo.name.length() == 0) {
callerInfo.name = null;
}
}
}catch(Exception e) {
Log.e(THIS_FILE, "Exception while retrieving cursor infos", e);
}finally {
cursor.close();
}
}
return callerInfo;
}
示例13: updateAvatarView
import android.provider.ContactsContract.Profile; //导入依赖的package包/类
private void updateAvatarView(String addr, boolean isSelf) {
Drawable avatarDrawable;
Log.v("MEssageListItem updateAvatarView", "Entered!!");
if (isSelf || !TextUtils.isEmpty(addr)) {
Contact contact = isSelf ? Contact.getMe(false) : Contact.get(addr,
false);
avatarDrawable = contact.getAvatar(mContext, sDefaultContactImage);
if (isSelf) {
mAvatar.assignContactUri(Profile.CONTENT_URI);
Log.v("MEssageListItem updateAvatarView isSelf", "Entered!!"
+ Profile.CONTENT_URI);
} else {
if (contact.existsInDatabase()) {
mAvatar.assignContactUri(contact.getUri());
Log.v("MEssageListItem updateAvatarView contact.existsInDatabase()",
"Entered!!" + contact.getUri());
} else {
mAvatar.assignContactFromPhone(contact.getNumber(), true);
Log.v("MEssageListItem updateAvatarView !contact.existsInDatabase()",
"Entered!!" + contact.getNumber());
}
}
} else {
avatarDrawable = sDefaultContactImage;
Log.v("MEssageListItem updateAvatarView !contact.existsInDatabase()",
"Entered!! ����else");
}
// zaizhe
// sDefaultContactImage =
// getResources().getDrawable(R.drawable.ic_contact_picture);
// avatarDrawable = sDefaultContactImage;
// zaizhe
Log.v("MessageListItem", "����������");
mAvatar.setImageDrawable(avatarDrawable);
}
示例14: updateAvatarView
import android.provider.ContactsContract.Profile; //导入依赖的package包/类
private void updateAvatarView(String addr, boolean isSelf) {
Drawable avatarDrawable;
Log.v("SimMessageListItem updateAvatarView", "Entered!!");
if (isSelf || !TextUtils.isEmpty(addr)) {
Contact contact = isSelf ? Contact.getMe(false) : Contact.get(addr,
false);
avatarDrawable = contact.getAvatar(mContext, sDefaultContactImage);
if (isSelf) {
mAvatar.assignContactUri(Profile.CONTENT_URI);
Log.v("SimMessageListItem updateAvatarView isSelf", "Entered!!"
+ Profile.CONTENT_URI);
} else {
if (contact.existsInDatabase()) {
mAvatar.assignContactUri(contact.getUri());
Log.v("SimMessageListItem updateAvatarView contact.existsInDatabase()",
"Entered!!" + contact.getUri());
} else {
mAvatar.assignContactFromPhone(contact.getNumber(), true);
Log.v("SimMessageListItem updateAvatarView !contact.existsInDatabase()",
"Entered!!" + contact.getNumber());
}
}
} else {
avatarDrawable = sDefaultContactImage;
Log.v("SimMessageListItem updateAvatarView !contact.existsInDatabase()",
"Entered!! ����else");
}
// zaizhe
// sDefaultContactImage =
// getResources().getDrawable(R.drawable.ic_contact_picture);
// avatarDrawable = sDefaultContactImage;
// zaizhe
Log.v("SimMessageListItem", "����������");
mAvatar.setImageDrawable(avatarDrawable);
}
示例15: onUpdateData
import android.provider.ContactsContract.Profile; //导入依赖的package包/类
@Override
protected void onUpdateData(int intReason) {
Log.d(getTag(), "Fetching phone owner information");
ExtensionData edtInformation = new ExtensionData();
setUpdateWhenScreenOn(false);
try {
Log.d(getTag(), "Get the phone owner from the Me contact");
Uri uriProfile = Uri.withAppendedPath(Profile.CONTENT_URI, Contacts.Data.CONTENT_DIRECTORY);
Cursor curOwner = getContentResolver().query(uriProfile,
new String[]{Email.ADDRESS, Email.IS_PRIMARY, Profile.DISPLAY_NAME,},
ContactsContract.Contacts.Data.MIMETYPE + " = ?",
new String[]{Email.CONTENT_ITEM_TYPE},
ContactsContract.Contacts.Data.IS_PRIMARY + " DESC");
if (!getString("heading", "").isEmpty()) {
edtInformation.expandedTitle(getString("heading", ""));
}
if (!getString("message", "").isEmpty()) {
edtInformation.expandedBody(getString("message", ""));
}
while (curOwner.moveToNext()) {
Integer intName = curOwner.getColumnIndex(ContactsContract.Profile.DISPLAY_NAME);
if (!curOwner.getString(intName).isEmpty() && edtInformation.expandedTitle() == null) {
edtInformation.expandedTitle(curOwner.getString(intName));
}
Integer intAddress = curOwner.getColumnIndex(ContactsContract.CommonDataKinds.Email.ADDRESS);
if (!curOwner.getString(intAddress).isEmpty() && edtInformation.expandedBody() == null) {
edtInformation.expandedBody(curOwner.getString(intAddress));
}
}
edtInformation.clickIntent(new Intent(Intent.ACTION_VIEW).setData(Profile.CONTENT_URI));
edtInformation.visible(true);
curOwner.close();
} catch (Exception e) {
edtInformation.visible(false);
Log.e(getTag(), "Encountered an error", e);
ACRA.getErrorReporter().handleSilentException(e);
}
edtInformation.icon(R.drawable.ic_dashclock);
doUpdate(edtInformation);
}