Java Code Examples for android.provider.ContactsContract.Contacts#CONTENT_URI

The following examples show how to use android.provider.ContactsContract.Contacts#CONTENT_URI . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ApiElevenPlus.java    From Linphone4Android with GNU General Public License v3.0 6 votes vote down vote up
public static Intent prepareAddContactIntent(String displayName, String sipUri) {
	Intent intent = new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI);
	intent.putExtra(Insert.NAME, displayName);
	
	if (sipUri != null && sipUri.startsWith("sip:")) {
		sipUri = sipUri.substring(4);
	}
	
	ArrayList<ContentValues> data = new ArrayList<ContentValues>();
	ContentValues sipAddressRow = new ContentValues();
	sipAddressRow.put(Contacts.Data.MIMETYPE, SipAddress.CONTENT_ITEM_TYPE);
	sipAddressRow.put(SipAddress.SIP_ADDRESS, sipUri);
	data.add(sipAddressRow);
	intent.putParcelableArrayListExtra(Insert.DATA, data);
	
	return intent;
}
 
Example 2
Source File: ContactsUtils5.java    From CSipSimple with GNU General Public License v3.0 6 votes vote down vote up
@Override
public Intent getAddContactIntent(String displayName, String csipUri) {
    Intent intent = new Intent(Intent.ACTION_INSERT_OR_EDIT, Contacts.CONTENT_URI);
    intent.setType(Contacts.CONTENT_ITEM_TYPE);

    if (!TextUtils.isEmpty(displayName)) {
        intent.putExtra(Insert.NAME, displayName);
    }

    if (!TextUtils.isEmpty(csipUri)) {
        ArrayList<ContentValues> data = new ArrayList<ContentValues>();
        ContentValues csipProto = new ContentValues();
        csipProto.put(Data.MIMETYPE, CommonDataKinds.Im.CONTENT_ITEM_TYPE);
        csipProto.put(CommonDataKinds.Im.PROTOCOL, CommonDataKinds.Im.PROTOCOL_CUSTOM);
        csipProto.put(CommonDataKinds.Im.CUSTOM_PROTOCOL, SipManager.PROTOCOL_CSIP);
        csipProto.put(CommonDataKinds.Im.DATA, SipUri.getCanonicalSipContact(csipUri, false));
        data.add(csipProto);

        intent.putParcelableArrayListExtra(Insert.DATA, data);
    }

    return intent;
}
 
Example 3
Source File: CursorFragment.java    From V.FlyoutTest with MIT License 6 votes vote down vote up
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    // This is called when a new Loader needs to be created.  This
    // sample only has one Loader, so we don't care about the ID.
    // First, pick the base URI to use depending on whether we are
    // currently filtering.
    Uri baseUri;
    if (mCurFilter != null) {
        baseUri = Uri.withAppendedPath(Contacts.CONTENT_FILTER_URI,
                Uri.encode(mCurFilter));
    } else {
        baseUri = Contacts.CONTENT_URI;
    }

    // Now create and return a CursorLoader that will take care of
    // creating a Cursor for the data being displayed.
    String select = "((" + Contacts.DISPLAY_NAME + " NOTNULL) AND ("
            + Contacts.HAS_PHONE_NUMBER + "=1) AND ("
            + Contacts.DISPLAY_NAME + " != '' ))";
    return new CursorLoader(getActivity(), baseUri,
            CONTACTS_SUMMARY_PROJECTION, select, null,
            Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC");
}
 
Example 4
Source File: LoaderCursor.java    From codeexamples-android with Eclipse Public License 1.0 6 votes vote down vote up
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    // This is called when a new Loader needs to be created.  This
    // sample only has one Loader, so we don't care about the ID.
    // First, pick the base URI to use depending on whether we are
    // currently filtering.
    Uri baseUri;
    if (mCurFilter != null) {
        baseUri = Uri.withAppendedPath(Contacts.CONTENT_FILTER_URI,
                Uri.encode(mCurFilter));
    } else {
        baseUri = Contacts.CONTENT_URI;
    }

    // Now create and return a CursorLoader that will take care of
    // creating a Cursor for the data being displayed.
    String select = "((" + Contacts.DISPLAY_NAME + " NOTNULL) AND ("
            + Contacts.HAS_PHONE_NUMBER + "=1) AND ("
            + Contacts.DISPLAY_NAME + " != '' ))";
    return new CursorLoader(getActivity(), baseUri,
            CONTACTS_SUMMARY_PROJECTION, select, null,
            Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC");
}
 
Example 5
Source File: ApiElevenPlus.java    From Linphone4Android with GNU General Public License v3.0 5 votes vote down vote up
public static Intent prepareEditContactIntentWithSipAddress(int id, String sipUri) {
	Intent intent = new Intent(Intent.ACTION_EDIT, Contacts.CONTENT_URI);
	Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, id);
	intent.setData(contactUri);
	
	ArrayList<ContentValues> data = new ArrayList<ContentValues>();
	ContentValues sipAddressRow = new ContentValues();
	sipAddressRow.put(Contacts.Data.MIMETYPE, SipAddress.CONTENT_ITEM_TYPE);
	sipAddressRow.put(SipAddress.SIP_ADDRESS, sipUri);
	data.add(sipAddressRow);
	intent.putParcelableArrayListExtra(Insert.DATA, data);
	
	return intent;
}
 
Example 6
Source File: ContactManager.java    From showCaseCordova with Apache License 2.0 5 votes vote down vote up
/**
 * Launches the Contact Picker to select a single contact.
 */
private void pickContactAsync() {
    final CordovaPlugin plugin = (CordovaPlugin) this;
    Runnable worker = new Runnable() {
        public void run() {
            Intent contactPickerIntent = new Intent(Intent.ACTION_PICK, Contacts.CONTENT_URI);
            plugin.cordova.startActivityForResult(plugin, contactPickerIntent, CONTACT_PICKER_RESULT);
        }
    };
    this.cordova.getThreadPool().execute(worker);
}
 
Example 7
Source File: DisplayActivity.java    From coursera-android with MIT License 5 votes vote down vote up
public Loader<Cursor> onCreateLoader(int id, Bundle args) {

		String select = "((" + Contacts.DISPLAY_NAME + " NOTNULL) AND ("
				+ Contacts.DISPLAY_NAME + " != '' ) AND (" + Contacts.STARRED
				+ "== 1))";

		return new CursorLoader(this, Contacts.CONTENT_URI, columnsToExtract,
				select, null, Contacts._ID + " ASC");
	}
 
Example 8
Source File: ContactsListExample.java    From coursera-android with MIT License 5 votes vote down vote up
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {

	// String used to filter contacts with empty or missing names or are unstarred
	String select = "((" + Contacts.DISPLAY_NAME + " NOTNULL) AND ("
			+ Contacts.DISPLAY_NAME + " != '' ) AND (" + Contacts.STARRED
			+ "== 1))";

	// String used for defining the sort order
	String sortOrder = Contacts._ID + " ASC";

	return new CursorLoader(this, Contacts.CONTENT_URI, CONTACTS_ROWS,
			select, null, sortOrder);
}
 
Example 9
Source File: DisplayActivity.java    From coursera-android with MIT License 5 votes vote down vote up
public Loader<Cursor> onCreateLoader(int id, Bundle args) {

        String select = "((" + Contacts.DISPLAY_NAME + " NOTNULL) AND ("
                + Contacts.DISPLAY_NAME + " != '' ) AND (" + Contacts.STARRED
                + "== 1))";

        return new CursorLoader(this, Contacts.CONTENT_URI, columnsToExtract,
                select, null, Contacts._ID + " ASC");
    }
 
Example 10
Source File: ContactsListActivity.java    From coursera-android with MIT License 5 votes vote down vote up
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {

    // String used to filter contacts with empty or missing names or are unstarred
    String select = "((" + Contacts.DISPLAY_NAME + " NOTNULL) AND ("
            + Contacts.DISPLAY_NAME + " != '' ) AND (" + Contacts.STARRED
            + "== 1))";

    // String used for defining the sort order
    String sortOrder = Contacts._ID + " ASC";

    return new CursorLoader(this, Contacts.CONTENT_URI, CONTACTS_ROWS,
            select, null, sortOrder);
}
 
Example 11
Source File: MainActivity.java    From SMS-Spammer-Android with MIT License 5 votes vote down vote up
@Override
public void onClick(View v) {
    if(v.getId() == btnContactPicker.getId()) {
        Intent contactsIntent = new Intent(Intent.ACTION_PICK, Contacts.CONTENT_URI);
        startActivityForResult(contactsIntent, ACTIVITYRESULT_CONTACTPICKER);
    } else if(v.getId() == btnStart.getId()) {
        if(txtAmmountOfMessages.getText().toString().equals("") || txtMessage.getText().toString().equals("") || txtPhoneNb.getText().toString().equals("")) {
            Toast.makeText(this, getString(R.string.errorFillAllFields), Toast.LENGTH_LONG).show();
        } else {
            initTimer();
        }
    } else if(v.getId() == btnStop.getId()) {
        cancelTimer();
    }
}
 
Example 12
Source File: ContactManager.java    From jpHolo with MIT License 5 votes vote down vote up
/**
 * Launches the Contact Picker to select a single contact.
 */
private void pickContactAsync() {
    final CordovaPlugin plugin = (CordovaPlugin) this;
    Runnable worker = new Runnable() {
        public void run() {
            Intent contactPickerIntent = new Intent(Intent.ACTION_PICK, Contacts.CONTENT_URI);
            plugin.cordova.startActivityForResult(plugin, contactPickerIntent, CONTACT_PICKER_RESULT);
        }
    };
    this.cordova.getThreadPool().execute(worker);
}
 
Example 13
Source File: FragmentContainer.java    From Contacts with MIT License 4 votes vote down vote up
protected Uri getUri()
{
	return Contacts.CONTENT_URI;
}