当前位置: 首页>>代码示例>>Java>>正文


Java Profile类代码示例

本文整理汇总了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);
		}
	}
}
 
开发者ID:syntafin,项目名称:TenguChat,代码行数:23,代码来源:PhoneHelper.java

示例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);
		}
	}
}
 
开发者ID:xavierle,项目名称:messengerxmpp,代码行数:23,代码来源:PhoneHelper.java

示例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;
}
 
开发者ID:moezbhatti,项目名称:qksms,代码行数:28,代码来源:Contact.java

示例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);
}
 
开发者ID:kriztan,项目名称:Pix-Art-Messenger,代码行数:20,代码来源:PhoneHelper.java

示例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);
}
 
开发者ID:siacs,项目名称:Conversations,代码行数:19,代码来源:PhoneHelper.java

示例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);
		}
	}
}
 
开发者ID:Frozenbox,项目名称:frozenchat,代码行数:23,代码来源:PhoneHelper.java

示例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);
		}
	}
}
 
开发者ID:juanignaciomolina,项目名称:txtr,代码行数:19,代码来源:PhoneHelper.java

示例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);
		}
	}
}
 
开发者ID:GitESS,项目名称:SyncChatAndroid,代码行数:19,代码来源:PhoneHelper.java

示例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);
}
 
开发者ID:slvn,项目名称:android-aosp-mms,代码行数:21,代码来源:MessageListItem.java

示例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;
}
 
开发者ID:moezbhatti,项目名称:qksms,代码行数:39,代码来源:Contact.java

示例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;
}
 
开发者ID:CommonQ,项目名称:sms_DualCard,代码行数:39,代码来源:Contact.java

示例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;
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:61,代码来源:ContactsUtils14.java

示例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);
}
 
开发者ID:CommonQ,项目名称:sms_DualCard,代码行数:46,代码来源:MessageListItem.java

示例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);
}
 
开发者ID:CommonQ,项目名称:sms_DualCard,代码行数:46,代码来源:SimMessageListItem.java

示例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);

}
 
开发者ID:mridang,项目名称:dashclock-owninfo,代码行数:54,代码来源:OwninfoWidget.java


注:本文中的android.provider.ContactsContract.Profile类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。