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


Java Phone.CONTENT_URI属性代码示例

本文整理汇总了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();
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:39,代码来源:TextSecureDirectory.java

示例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();
	}
}
 
开发者ID:arunrajora,项目名称:Chit-Chat,代码行数:8,代码来源:IntentUtils.java

示例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();
  }
}
 
开发者ID:redcracker,项目名称:TextSecure,代码行数:39,代码来源:TextSecureDirectory.java

示例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);
}
 
开发者ID:Egorand,项目名称:android-testing-runtime-permissions,代码行数:7,代码来源:MainActivity.java

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

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

示例7: getPhoneContentUri

/**
 * Get the CONTENT_URI from Phone for PhoneNumberPicker.
 */
public static Uri getPhoneContentUri() {
  return Phone.CONTENT_URI;
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:6,代码来源:HoneycombMR1Util.java

示例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");
}
 
开发者ID:rapidpro,项目名称:ureport-android,代码行数:5,代码来源:InviteContactsFragment.java

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


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