当前位置: 代码迷 >> Android >> android联系人、短信、邮件url小结
  详细解决方案

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

热度:34   发布时间:2016-05-01 18:42:20.0
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:[email protected]");             Intent MymailIntent=new Intent(Intent.ACTION_SEND,uri);             startActivity(MymailIntent); 

?方法二:

?

Intent testintent=new Intent(Intent.ACTION_SEND);             String[] tos={"[email protected]"};             String[] ccs={"[email protected]"};             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);

??

  相关解决方案