本文整理汇总了Java中android.provider.ContactsContract.CommonDataKinds.Phone.CONTENT_URI属性的典型用法代码示例。如果您正苦于以下问题:Java Phone.CONTENT_URI属性的具体用法?Java Phone.CONTENT_URI怎么用?Java Phone.CONTENT_URI使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.provider.ContactsContract.CommonDataKinds.Phone
的用法示例。
在下文中一共展示了Phone.CONTENT_URI属性的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPushEligibleContactNumbers
public Set<String> getPushEligibleContactNumbers(String localNumber) {
final Uri uri = Phone.CONTENT_URI;
final Set<String> results = new HashSet<>();
Cursor cursor = null;
try {
cursor = context.getContentResolver().query(uri, new String[] {Phone.NUMBER}, null, null, null);
while (cursor != null && cursor.moveToNext()) {
final String rawNumber = cursor.getString(0);
if (rawNumber != null) {
try {
final String e164Number = PhoneNumberFormatter.formatNumber(rawNumber, localNumber);
results.add(e164Number);
} catch (InvalidNumberException e) {
Log.w("Directory", "Invalid number: " + rawNumber);
}
}
}
if (cursor != null)
cursor.close();
final SQLiteDatabase readableDb = databaseHelper.getReadableDatabase();
if (readableDb != null) {
cursor = readableDb.query(TABLE_NAME, new String[]{NUMBER},
null, null, null, null, null);
while (cursor != null && cursor.moveToNext()) {
results.add(cursor.getString(0));
}
}
return results;
} finally {
if (cursor != null)
cursor.close();
}
}
示例2: fireContactPickerIntent
public static void fireContactPickerIntent(Fragment fragment, int requestCode) {
Intent pickContactIntent = new Intent(ACTION_PICK, Phone.CONTENT_URI);
if (pickContactIntent.resolveActivity(fragment.getContext().getPackageManager()) != null) {
fragment.startActivityForResult(pickContactIntent, requestCode);
} else {
Toast.makeText(fragment.getContext(), string.cc_no_cpicker, Toast.LENGTH_SHORT).show();
}
}
示例3: getPushEligibleContactNumbers
public Set<String> getPushEligibleContactNumbers(String localNumber) {
final Uri uri = Phone.CONTENT_URI;
final Set<String> results = new HashSet<String>();
Cursor cursor = null;
try {
cursor = context.getContentResolver().query(uri, new String[] {Phone.NUMBER}, null, null, null);
while (cursor != null && cursor.moveToNext()) {
final String rawNumber = cursor.getString(0);
if (rawNumber != null) {
try {
final String e164Number = PhoneNumberFormatter.formatNumber(rawNumber, localNumber);
results.add(e164Number);
} catch (InvalidNumberException e) {
Log.w("Directory", "Invalid number: " + rawNumber);
}
}
}
if (cursor != null)
cursor.close();
final SQLiteDatabase readableDb = databaseHelper.getReadableDatabase();
if (readableDb != null) {
cursor = readableDb.query(TABLE_NAME, new String[]{NUMBER},
null, null, null, null, null);
while (cursor != null && cursor.moveToNext()) {
results.add(cursor.getString(0));
}
}
return results;
} finally {
if (cursor != null)
cursor.close();
}
}
示例4: onCreateLoader
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
String[] columns = {Phone._ID, Phone.DISPLAY_NAME_PRIMARY, Phone.DATA};
String selection = Data.MIMETYPE + " = '" + Phone.CONTENT_ITEM_TYPE + "'";
String orderBy = Phone.DISPLAY_NAME_PRIMARY + " ASC";
return new CursorLoader(this, Phone.CONTENT_URI, columns, selection, null, orderBy);
}
示例5: onActivityCreated
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
long personId = getArguments().getLong(ContactsPickerActivity.SELECTED_CONTACT_ID);// getIntent().getLongExtra("id", 0);
Activity activity = getActivity();
Uri phonesUri = Phone.CONTENT_URI;
String[] projection = new String[] {
Phone._ID, Phone.DISPLAY_NAME,
Phone.TYPE, Phone.NUMBER, Phone.LABEL };
String selection = Phone.CONTACT_ID + " = ?";
String[] selectionArgs = new String[] { Long.toString(personId) };
mCursor = activity.getContentResolver().query(phonesUri,
projection, selection, selectionArgs, null);
mDisplayName = (TextView) activity.findViewById(R.id.display_name);
if (mCursor.moveToFirst()){
mDisplayName.setText(mCursor.getString(mCursor.getColumnIndex(Phone.DISPLAY_NAME)));
}
ListAdapter adapter = new PhoneNumbersAdapter(this.getActivity(),
R.layout.list_item_phone_number, mCursor,
new String[] {Phone.TYPE, Phone.NUMBER },
new int[] { R.id.label, R.id.phone_number });
setListAdapter(adapter);
}
示例6: getNumbers
public List<String> getNumbers(Context context) {
List<String> phoneNumbers = new LinkedList<>();
Uri uri = Phone.CONTENT_URI;
String[] projection = new String[] {
Phone.NUMBER,
Phone.IS_PRIMARY
};
String clause = Phone.CONTACT_ID + " = ?";
String[] args = new String[] { getId() };
Cursor cursor = context.getContentResolver().query(uri, projection, clause, args, null);
if (cursor != null) {
try {
if (cursor.moveToFirst()) {
do {
boolean isPrimary = cursor.getInt(cursor.getColumnIndex(Phone.IS_PRIMARY)) != 0;
String number = cursor.getString(cursor.getColumnIndex(Phone.NUMBER));
if (isPrimary) {
phoneNumbers.add(0, number);
} else {
phoneNumbers.add(number);
}
} while (cursor.moveToNext());
}
} finally {
cursor.close();
}
}
return phoneNumbers;
}
示例7: getPhoneContentUri
/**
* Get the CONTENT_URI from Phone for PhoneNumberPicker.
*/
public static Uri getPhoneContentUri() {
return Phone.CONTENT_URI;
}
示例8: onCreateLoader
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
return new CursorLoader(getActivity(), Phone.CONTENT_URI, PROJECTION, null, null
, Phone.DISPLAY_NAME + " ASC");
}
示例9: getMobileNumber
public synchronized Future<String> getMobileNumber(final Context context) {
if (mNumber != null) {
return new Present<>(mNumber);
} else {
return new FutureImpl<String>() {
@Override
public String get() {
List<String> numbers = new LinkedList<>();
Uri uri = Phone.CONTENT_URI;
String[] projection = new String[] {
Phone.NUMBER,
Phone.IS_PRIMARY,
Phone.TYPE
};
String clause = Phone.CONTACT_ID + " = ? AND " + Phone.TYPE + " = ?";
String[] args = new String[] { getId(), Integer.toString(Phone.TYPE_MOBILE) };
Cursor cursor = context.getContentResolver().query(uri, projection, clause, args, null);
if (cursor != null) {
try {
if (cursor.moveToFirst()) {
do {
boolean isPrimary = cursor.getInt(cursor.getColumnIndex(Phone.IS_PRIMARY)) != 0;
String number = cursor.getString(cursor.getColumnIndex(Phone.NUMBER));
if (isPrimary) {
numbers.add(0, number);
} else {
numbers.add(number);
}
} while (cursor.moveToNext());
}
} finally {
cursor.close();
}
}
if (numbers.isEmpty()) {
return null;
} else {
return setNumber(numbers.get(0));
}
}
};
}
}