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


Java RawContacts类代码示例

本文整理汇总了Java中android.provider.ContactsContract.RawContacts的典型用法代码示例。如果您正苦于以下问题:Java RawContacts类的具体用法?Java RawContacts怎么用?Java RawContacts使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


RawContacts类属于android.provider.ContactsContract包,在下文中一共展示了RawContacts类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addContactVoiceSupport

import android.provider.ContactsContract.RawContacts; //导入依赖的package包/类
private void addContactVoiceSupport(List<ContentProviderOperation> operations,
                                    @NonNull String e164number, long rawContactId)
{
  operations.add(ContentProviderOperation.newUpdate(RawContacts.CONTENT_URI)
                                         .withSelection(RawContacts._ID + " = ?", new String[] {String.valueOf(rawContactId)})
                                         .withValue(RawContacts.SYNC4, "true")
                                         .build());

  operations.add(ContentProviderOperation.newInsert(ContactsContract.Data.CONTENT_URI.buildUpon().appendQueryParameter(ContactsContract.CALLER_IS_SYNCADAPTER, "true").build())
                                         .withValue(ContactsContract.Data.RAW_CONTACT_ID, rawContactId)
                                         .withValue(ContactsContract.Data.MIMETYPE, CALL_MIMETYPE)
                                         .withValue(ContactsContract.Data.DATA1, e164number)
                                         .withValue(ContactsContract.Data.DATA2, context.getString(R.string.app_name))
                                         .withValue(ContactsContract.Data.DATA3, context.getString(R.string.ContactsDatabase_signal_call_s, e164number))
                                         .withYieldAllowed(true)
                                         .build());
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:18,代码来源:ContactsDatabase.java

示例2: onOptionsItemSelected

import android.provider.ContactsContract.RawContacts; //导入依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
	switch (item.getItemId()) {
		case id.menu_edit_profile:
			Intent intent = new Intent(getActivity(), ProfileEditActivity.class);
			startActivity(intent);
			break;
		case id.menu_add_contact:
			Intent add_contact_intent = new Intent(Insert.ACTION);
			add_contact_intent.setType(RawContacts.CONTENT_TYPE);
			startActivityForResult(add_contact_intent, TAG_ADD_CONTACT);
			break;
		case id.menu_about:
			Intent about_intent = new Intent(getActivity(), AboutActivity.class);
			startActivity(about_intent);
			break;
	}
	return super.onOptionsItemSelected(item);
}
 
开发者ID:arunrajora,项目名称:Chit-Chat,代码行数:20,代码来源:FragmentChatLists.java

示例3: addContact

import android.provider.ContactsContract.RawContacts; //导入依赖的package包/类
public static void addContact(String name, String number)
{
	ContentValues values = new ContentValues(); 
       //������RawContacts.CONTENT_URIִ��һ����ֵ���룬Ŀ���ǻ�ȡϵͳ���ص�rawContactId  
       Uri rawContactUri = m_context.getContentResolver().insert(RawContacts.CONTENT_URI, values); 
       long rawContactId = ContentUris.parseId(rawContactUri); 
       //��data������������� 
       values.clear(); 
       values.put(Data.RAW_CONTACT_ID, rawContactId);  
       values.put(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE);//�������� 
       values.put(StructuredName.GIVEN_NAME, name); 
       m_context.getContentResolver().insert(ContactsContract.Data.CONTENT_URI, values);
      
       //��data�����绰���� 
       values.clear(); 
       values.put(Data.RAW_CONTACT_ID, rawContactId); 
       values.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE); 
       values.put(Phone.NUMBER, number); 
       values.put(Phone.TYPE, Phone.TYPE_MOBILE); 
       m_context.getContentResolver().insert(ContactsContract.Data.CONTENT_URI, values); 
       
}
 
开发者ID:nighthary,项目名称:phoneContact,代码行数:23,代码来源:Utils.java

示例4: clearAllContacts

import android.provider.ContactsContract.RawContacts; //导入依赖的package包/类
private void clearAllContacts(final JSONObject contactOptions, final String requestID) {
    ArrayList<ContentProviderOperation> deleteOptions = new ArrayList<ContentProviderOperation>();

    // Delete all contacts from the selected account
    ContentProviderOperation.Builder deleteOptionsBuilder = ContentProviderOperation.newDelete(RawContacts.CONTENT_URI);
    if (mAccountName != null) {
        deleteOptionsBuilder.withSelection(RawContacts.ACCOUNT_NAME + "=?", new String[] {mAccountName})
                            .withSelection(RawContacts.ACCOUNT_TYPE + "=?", new String[] {mAccountType});
    }

    deleteOptions.add(deleteOptionsBuilder.build());

    // Clear the contacts
    String returnStatus = "KO";
    if (applyBatch(deleteOptions) != null) {
        returnStatus = "OK";
    }

    Log.i(LOGTAG, "Sending return status: " + returnStatus);

    sendCallbackToJavascript("Android:Contacts:Clear:Return:" + returnStatus, requestID,
                             new String[] {"contactID"}, new Object[] {"undefined"});

}
 
开发者ID:jrconlin,项目名称:mc_backup,代码行数:25,代码来源:ContactService.java

示例5: getAllRawContactIdsCursor

import android.provider.ContactsContract.RawContacts; //导入依赖的package包/类
private Cursor getAllRawContactIdsCursor() {
    // When a contact is deleted, it actually just sets the deleted field to 1 until the
    // sync adapter actually deletes the contact later so ignore any contacts with the deleted
    // flag set
    String selection = RawContacts.DELETED + "=0";
    String[] selectionArgs = null;

    // Only get contacts from the selected account
    if (mAccountName != null) {
        selection += " AND " + RawContacts.ACCOUNT_NAME + "=? AND " + RawContacts.ACCOUNT_TYPE + "=?";
        selectionArgs = new String[] {mAccountName, mAccountType};
    }

    // Get the ID's of all contacts and use the number of contact ID's as
    // the total number of contacts
    return mContentResolver.query(RawContacts.CONTENT_URI, new String[] {RawContacts._ID},
                                  selection, selectionArgs, null);
}
 
开发者ID:jrconlin,项目名称:mc_backup,代码行数:19,代码来源:ContactService.java

示例6: addContact

import android.provider.ContactsContract.RawContacts; //导入依赖的package包/类
/**
 * Synchronously insert a contact with the designated @name into
 * the ContactsContentProvider.  This code is explained at
 * http://developer.android.com/reference/android/provider/ContactsContract.RawContacts.html.
 */
private void addContact(String name,
                        List<ContentProviderOperation> cpops) {
    final int position = cpops.size();

    // First part of operation.
    cpops.add(ContentProviderOperation.newInsert(RawContacts.CONTENT_URI)
              .withValue(RawContacts.ACCOUNT_TYPE,
                         mOps.getAccountType())
              .withValue(RawContacts.ACCOUNT_NAME,
                         mOps.getAccountName())
              .withValue(Contacts.STARRED,
                         1)
              .build());

    // Second part of operation.
    cpops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI)
              .withValueBackReference(Data.RAW_CONTACT_ID,
                                      position)
              .withValue(Data.MIMETYPE,
                         StructuredName.CONTENT_ITEM_TYPE)
              .withValue(StructuredName.DISPLAY_NAME,
                         name)
              .build());
}
 
开发者ID:juleswhite,项目名称:mobilecloud-15,代码行数:30,代码来源:InsertContactsCommand.java

示例7: executeImpl

import android.provider.ContactsContract.RawContacts; //导入依赖的package包/类
/**
 * Each contact requires two (asynchronous) insertions into
 * the Contacts Provider.  The first insert puts the
 * RawContact into the Contacts Provider and the second insert
 * puts the data associated with the RawContact into the
 * Contacts Provider.
 */
public void executeImpl() {
    if (getArgs().getIterator().hasNext()) {
        // If there are any contacts left to insert, make a
        // ContentValues object containing the RawContact
        // portion of the contact and initiate an asynchronous
        // insert on the Contacts ContentProvider.
        final ContentValues values = makeRawContact(1);
        getArgs().getAdapter()
                 .startInsert(this,
                              INSERT_RAW_CONTACT,
                              RawContacts.CONTENT_URI,
                              values);
    } else
        // Otherwise, print a toast with summary info.
        Utils.showToast(getArgs().getOps().getActivityContext(),
                        getArgs().getCounter().getValue()
                        +" contact(s) inserted");
}
 
开发者ID:juleswhite,项目名称:mobilecloud-15,代码行数:26,代码来源:InsertContactsCommand.java

示例8: updateClientMod

import android.provider.ContactsContract.RawContacts; //导入依赖的package包/类
/**
 * Update the custom row-modification-date
 * 
 * @param serverId
 *            the serverId for this contact
 * @param uri
 *            Uri for the existing raw contact to be updated
 * @return instance of ContactOperations
 */
public ContactOperations updateClientMod(Long version, Long clientMod,
		Uri uri) {
	mValues.clear();
	if (clientMod != null) {
		mValues.put(RawContacts.SYNC2, clientMod);
	}
	mValues.put(RawContacts.SYNC3, version);
	if (Log.isLoggable(TAG, Log.INFO)) {
		Log.i(TAG, "ClientMod updated: "
				+ (clientMod != null ? new Date(clientMod).toString()
						: "null") + ",version:" + version
				+ " for contactId:" + ContentUris.parseId(uri));
	}
	addUpdateOp(uri);
	return this;
}
 
开发者ID:mgrieder,项目名称:ntsync-android,代码行数:26,代码来源:ContactOperations.java

示例9: populatePhoto

import android.provider.ContactsContract.RawContacts; //导入依赖的package包/类
protected void populatePhoto(Contact c) throws RemoteException {
	@Cleanup Cursor cursor = providerClient.query(dataURI(),
			new String[] { Photo.PHOTO_FILE_ID, Photo.PHOTO },
			Photo.RAW_CONTACT_ID + "=? AND " + Data.MIMETYPE + "=?",
			new String[] { String.valueOf(c.getLocalID()), Photo.CONTENT_ITEM_TYPE }, null);
	if (cursor != null && cursor.moveToNext()) {
		if (!cursor.isNull(0)) {
			Uri photoUri = Uri.withAppendedPath(
		             ContentUris.withAppendedId(RawContacts.CONTENT_URI, c.getLocalID()),
		             RawContacts.DisplayPhoto.CONTENT_DIRECTORY);
			try {
				@Cleanup AssetFileDescriptor fd = providerClient.openAssetFile(photoUri, "r");
				@Cleanup InputStream is = fd.createInputStream();
				c.setPhoto(IOUtils.toByteArray(is));
			} catch(IOException ex) {
				Log.w(TAG, "Couldn't read high-res contact photo", ex);
			}
		} else
			c.setPhoto(cursor.getBlob(1));
	}
}
 
开发者ID:eXfio,项目名称:CucumberSync,代码行数:22,代码来源:LocalAddressBook.java

示例10: EasyDb

import android.provider.ContactsContract.RawContacts; //导入依赖的package包/类
public EasyDb(long contactId) {
	cursor = context.getContentResolver().query(
		RawContacts.CONTENT_URI,
		new String[]{RawContacts._ID,
			RawContacts.CONTACT_ID, RawContacts.AGGREGATION_MODE,
			RawContacts.DELETED, RawContacts.TIMES_CONTACTED,
			RawContacts.LAST_TIME_CONTACTED, RawContacts.STARRED,
			RawContacts.CUSTOM_RINGTONE, RawContacts.SEND_TO_VOICEMAIL,
			RawContacts.ACCOUNT_NAME, RawContacts.ACCOUNT_TYPE,
			RawContacts.DATA_SET, RawContacts.SOURCE_ID,
			RawContacts.VERSION, RawContacts.DIRTY, RawContacts.SYNC1,
			RawContacts.SYNC2, RawContacts.SYNC3, RawContacts.SYNC4, },
		RawContacts.CONTACT_ID + "=?",
		new String[]{String.valueOf(contactId)},
		null);
	cursor.moveToFirst();
	columnNames = cursor.getColumnNames();
}
 
开发者ID:emdete,项目名称:Simplicissimus,代码行数:19,代码来源:EasyDb.java

示例11: Parcels

import android.provider.ContactsContract.RawContacts; //导入依赖的package包/类
public Parcels(Context context, long contactId) {
	this.context = context;
	cursor = context.getContentResolver().query(
		RawContacts.CONTENT_URI,
		new String[]{RawContacts._ID,
			RawContacts.CONTACT_ID, RawContacts.AGGREGATION_MODE,
			RawContacts.DELETED, RawContacts.TIMES_CONTACTED,
			RawContacts.LAST_TIME_CONTACTED, RawContacts.STARRED,
			RawContacts.CUSTOM_RINGTONE, RawContacts.SEND_TO_VOICEMAIL,
			RawContacts.ACCOUNT_NAME, RawContacts.ACCOUNT_TYPE,
			RawContacts.DATA_SET, RawContacts.SOURCE_ID,
			RawContacts.VERSION, RawContacts.DIRTY, RawContacts.SYNC1,
			RawContacts.SYNC2, RawContacts.SYNC3, RawContacts.SYNC4, },
		RawContacts.CONTACT_ID + "=?",
		new String[]{String.valueOf(contactId)},
		null);
	//cursor.moveToFirst();
	columnNames = cursor.getColumnNames();
}
 
开发者ID:emdete,项目名称:Simplicissimus,代码行数:20,代码来源:Parcels.java

示例12: getContactDetails

import android.provider.ContactsContract.RawContacts; //导入依赖的package包/类
private void getContactDetails(long id){
Cursor cursor = getActivity().getContentResolver().query(RawContacts.CONTENT_URI, new String[] {RawContacts._ID, RawContacts.DISPLAY_NAME_PRIMARY, RawContacts.CONTACT_ID, RawContacts.SYNC1}, RawContacts._ID + "=" +id, null, null);
if (cursor.getColumnCount() >= 1){
	cursor.moveToFirst();
	name = cursor.getString(cursor.getColumnIndex(RawContacts.DISPLAY_NAME_PRIMARY));
	uid = cursor.getString(cursor.getColumnIndex(RawContacts.SYNC1));
	joined = ContactUtil.getMergedContacts(getActivity(), id);
	contactID = cursor.getLong(cursor.getColumnIndex(RawContacts.CONTACT_ID));
	
}
cursor.close();
imageURI = Uri.withAppendedPath(
ContentUris.withAppendedId(RawContacts.CONTENT_URI, id),
      RawContacts.DisplayPhoto.CONTENT_DIRECTORY);
Log.i("imageuri", imageURI.toString());
  }
 
开发者ID:mots,项目名称:haxsync,代码行数:17,代码来源:ContactDetailFragment.java

示例13: onActivityCreated

import android.provider.ContactsContract.RawContacts; //导入依赖的package包/类
@Override
  public void onActivityCreated(Bundle savedInstanceState) {
      super.onActivityCreated(savedInstanceState);
      
      setEmptyText(getActivity().getString(R.string.no_contacts));
      setHasOptionsMenu(true);


String[] columns = new String[] {RawContacts.DISPLAY_NAME_PRIMARY};
int[] to = new int[] { android.R.id.text1 };
mAdapter = new ContactsCursorAdapter(
        getActivity(),
        android.R.layout.simple_list_item_activated_1, 
        null,
        columns,
        to,
        0);
setListAdapter(mAdapter);
showSyncIndicator();
   mContentProviderHandle = ContentResolver.addStatusChangeListener(
             ContentResolver.SYNC_OBSERVER_TYPE_ACTIVE, this);

  }
 
开发者ID:mots,项目名称:haxsync,代码行数:24,代码来源:ContactListFragment.java

示例14: getMergedContact

import android.provider.ContactsContract.RawContacts; //导入依赖的package包/类
public static Contact getMergedContact(Context c, long contactID, Account account){
  	
Uri ContactUri = RawContacts.CONTENT_URI.buildUpon()
		.appendQueryParameter(RawContacts.ACCOUNT_NAME, account.name)
		.appendQueryParameter(RawContacts.ACCOUNT_TYPE, account.type)
		.build();
  	
Cursor cursor = c.getContentResolver().query(ContactUri, new String[] { BaseColumns._ID, RawContacts.DISPLAY_NAME_PRIMARY}, RawContacts.CONTACT_ID +" = '" + contactID + "'", null, null);
if (cursor.getCount() > 0){
	cursor.moveToFirst();
	Contact contact = new Contact();
	contact.ID = cursor.getLong(cursor.getColumnIndex(BaseColumns._ID));
	contact.name = cursor.getString(cursor.getColumnIndex(RawContacts.DISPLAY_NAME_PRIMARY));
	cursor.close();
	return contact;
}
cursor.close();
return null;

  }
 
开发者ID:mots,项目名称:haxsync,代码行数:21,代码来源:ContactUtil.java

示例15: getRawContacts

import android.provider.ContactsContract.RawContacts; //导入依赖的package包/类
public static Set<Long> getRawContacts(ContentResolver c, long rawContactID, String accountType){
	HashSet<Long> ids = new HashSet<Long>();
	Cursor cursor = c.query(RawContacts.CONTENT_URI, new String[] { RawContacts.CONTACT_ID}, RawContacts._ID +" = '" + rawContactID + "'", null, null);	
	if (cursor.getCount() > 0){
		cursor.moveToFirst();
		long contactID = cursor.getLong(cursor.getColumnIndex(RawContacts.CONTACT_ID));
		//	Log.i("QUERY", RawContacts.CONTACT_ID +" = '" + contactID + "'" + " AND " + BaseColumns._ID + " != " +rawContactID + " AND " + RawContacts.ACCOUNT_TYPE + " = '" + accountType+"'");
			Cursor c2 = c.query(RawContacts.CONTENT_URI, new String[] { BaseColumns._ID}, RawContacts.CONTACT_ID +" = '" + contactID + "'" + " AND " + BaseColumns._ID + " != " +rawContactID + " AND " + RawContacts.ACCOUNT_TYPE + " = '" + accountType+"'", null, null);
		//	Log.i("CURSOR SIZE", String.valueOf(c2.getCount()));
			while (c2.moveToNext()){
				ids.add(c2.getLong(c2.getColumnIndex(BaseColumns._ID)));
			}
			c2.close();
	}
	cursor.close();
	return ids;
}
 
开发者ID:mots,项目名称:haxsync,代码行数:18,代码来源:ContactUtil.java


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