android联系人、短信、邮件url总结

 到打电话界面

uri = Uri.parse("tel:"+number);
				intent = new Intent(Intent.ACTION_CALL,uri);
				startActivity(intent);

 

 

到发送短信页面

uri = Uri.parse("smsto:"+要发送短信的对方的number);
				intent = new Intent(Intent.ACTION_SENDTO,uri);
				startActivity(intent);

 另一种

 

mIntent = new Intent(Intent.ACTION_VIEW);
		mIntent.putExtra("address", c.getString(c.getColumnIndex(column)));
		mIntent.setType("vnd.android-dir/mms-sms");
		startActivity(mIntent); 

 

 

添加到短信收件箱

 

ContentValues cv = new ContentValues();    
				cv.put("type", "1"); 
cv.put("address","短信地址");
cv.put("body", "短信内容"); 
getContentResolver().insert(Uri.parse("content://sms/inbox"), cv); 

 

 

从sim卡或者联系人中查询

Cursor cursor;
		Uri uri;
		if (type == 1) {
			Intent intent = new Intent();
			intent.setData(Uri.parse("content://icc/adn"));
			uri = intent.getData();
		} else
			uri = People.CONTENT_URI;

		cursor = activity.getContentResolver().query(uri, null, null, null, null);
while (cursor.moveToNext()) {
     int peopleId = cursor.getColumnIndex(People._ID);
   int nameId = cursor.getColumnIndex(People.NAME);
   int phoneId = cursor.getColumnIndex(People.NUMBER);}

 删除

uri = ContentUris.withAppendedId(People.CONTENT_URI, 联系人id);
		int count = activity.getContentResolver().delete(uri, null, null);

 

添加到联系人:

ContentValues cv = new ContentValues();
					ArrayList<ContentProviderOperation> operationList = new ArrayList<ContentProviderOperation>();
					ContentProviderOperation.Builder builder = ContentProviderOperation.newInsert(RawContacts.CONTENT_URI);
					builder.withValues(cv);
					operationList.add(builder.build());
					builder = ContentProviderOperation.newInsert(Data.CONTENT_URI);
					builder.withValueBackReference(StructuredName.RAW_CONTACT_ID, 0);
	                builder.withValue(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE);
	                builder.withValue(StructuredName.DISPLAY_NAME, "自定义联系人名");
	                operationList.add(builder.build());
	                builder = ContentProviderOperation.newInsert(Data.CONTENT_URI);
	                builder.withValueBackReference(Phone.RAW_CONTACT_ID, 0);
	                builder.withValue(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE);
	                builder.withValue(Phone.NUMBER, "联系人的phonenumber");
	                builder.withValue(Data.IS_PRIMARY, 1);
	                operationList.add(builder.build());
	                try {
	                	getContentResolver().applyBatch(ContactsContract.AUTHORITY, operationList);
					} catch (RemoteException e) {
						e.printStackTrace();
					} catch (OperationApplicationException e) {
						e.printStackTrace();
					}

 

 

动作Uri说明

Intent.ACTION_VIEW

geo:latitude,longtitude

打开地图应用程序并显示指定的纬度和经度

Intent.ACTION_VIEW

geo:0,0?q=street+address

打开地图应用程序并显示指定的地址

Intent.ACTION_CALL

tel:phone_number

打开电话应用程序并拨打指定的电话号码

Intent.ACTION_DIAL

tel:phone_number

打开电话应用程序并拨下指定电话(但不打出)

Intent.ACTION_DIAL

voicemail:

打开电话应用程序并拨下语音信箱号码(但不打出)

Intent.ACTION_VIEW

http://web_address

打开浏览器应用程序并显示指定的URL

Intent.ACTION_VIEW

https://web_address

打开浏览器应用程序并显示指定的URL

Intent.ACTION_WEB_SEARCH

plain_text

打开浏览器应用程序并使用Google搜索引擎

 

发送邮件:

 

Uri uri=Uri.parse("mailto:terryyhl@gmail.com"); 
            Intent MymailIntent=new Intent(Intent.ACTION_SEND,uri); 
            startActivity(MymailIntent); 

 方法二:

 

Intent testintent=new Intent(Intent.ACTION_SEND); 
            String[] tos={"terryyhl@gmail.com"}; 
            String[] ccs={"kalaicheng@hotmail.com"}; 
            testintent.putExtra(Intent.EXTRA_EMAIL, tos); 
            testintent.putExtra(Intent.EXTRA_CC, ccs); 
            testintent.putExtra(Intent.EXTRA_TEXT, "这是内容"); 
            testintent.putExtra(Intent.EXTRA_SUBJECT, "这是标题"); 
            testintent.setType("message/rfc822"); 
            startActivity(Intent.createChooser(testintent, "发送")); 

 

播放多媒体:

 

//播放多媒体
Intent it = new Intent(Intent.ACTION_VIEW);
Uri uri = Uri.parse("file:///sdcard/song.mp3");it.setDataAndType(uri, "audio/mp3");
startActivity(it);
Uri uri = Uri.withAppendedPath(MediaStore.Audio.Media.INTERNAL_CONTENT_URI, "1");
Intent it = new Intent(Intent.ACTION_VIEW, uri);startActivity(it);

  

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值