手机软件功能开发(4)

时间:2025-04-23

Android手机系统的手机功能开发例子

/**

* 增加一条联系人

*/

private void insertContactsDialog() {

View view = View.inflate(this, yout.insert_contacts_layout,null);

final EditText username_handle = (EditText) view.findViewById(R.id.insert_contacts_layout_edittext_username);

final EditText password_handle = (EditText) view.findViewById(R.id.insert_contacts_layout_edittext_password);

final AlertDialog.Builder myBuilder = new AlertDialog.Builder(this);

myBuilder.setIcon(android.R.drawable.ic_dialog_info);

myBuilder.setTitle(R.string.insertContacts);

myBuilder.setView(view);

myBuilder.setPositiveButton(R.string.certain,new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) {

String peopleName = username_handle.getText().toString(); String phoneNum = password_handle.getText().toString();

//信息储存容器

ContentValues contentValues = new ContentValues();

//将联系人名放入ContentValues

contentValues.put(contacts_lable[1], peopleName);

//添加的位置 0为联系人, 1 为联系人+收藏夹 contentValues.put(People.STARRED, 0);

//将名字添加到联系人列表并得到添加的Uri

Uri peopleUri = People.createPersonInMyContactsGroup(getContentResolver(), contentValues);

Log.e("peopleUri:",""+peopleUri.toString());

Uri phoneNumUri = Uri.withAppendedPath(peopleUri, People.Phones.CONTENT_DIRECTORY);

Log.e("phoneNumUri:",""+phoneNumUri.toString());

} //清除信息容器中旧的信息 contentValues.clear(); //放入新的信息 contentValues.put(People.TYPE, People.TYPE_OTHER); contentValues.put(contacts_lable[2], phoneNum); //插入联系人电话信息 getContentResolver().insert(phoneNumUri, contentValues); queryContacts("*");

手机软件功能开发(4).doc 将本文的Word文档下载到电脑

精彩图片

热门精选

大家正在看

× 游客快捷下载通道(下载后可以自由复制和排版)

限时特价:7 元/份 原价:20元

支付方式:

开通VIP包月会员 特价:29元/月

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219