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

    博客分类:
  • android

到打电话界面

Java代码
  1. uri=Uri.parse("tel:"+number);
  2. intent=newIntent(Intent.ACTION_CALL,uri);
  3. startActivity(intent);

到发送短信页面

Java代码
  1. uri=Uri.parse("smsto:"+要发送短信的对方的number);
  2. intent=newIntent(Intent.ACTION_SENDTO,uri);
  3. startActivity(intent);

另一种

Java代码
  1. mIntent=newIntent(Intent.ACTION_VIEW);
  2. mIntent.putExtra("address",c.getString(c.getColumnIndex(column)));
  3. mIntent.setType("vnd.android-dir/mms-sms");
  4. startActivity(mIntent);

添加到短信收件箱

Java代码
  1. ContentValuescv=newContentValues();
  2. cv.put("type","1");
  3. cv.put("address","短信地址");
  4. cv.put("body","短信内容");
  5. getContentResolver().insert(Uri.parse("content://sms/inbox"),cv);

从sim卡或者联系人中查询

Java代码
  1. Cursorcursor;
  2. Uriuri;
  3. if(type==1){
  4. Intentintent=newIntent();
  5. intent.setData(Uri.parse("content://icc/adn"));
  6. uri=intent.getData();
  7. }else
  8. uri=People.CONTENT_URI;
  9. cursor=activity.getContentResolver().query(uri,null,null,null,null);
Java代码
  1. while(cursor.moveToNext()){
  2. intpeopleId=cursor.getColumnIndex(People._ID);
  3. intnameId=cursor.getColumnIndex(People.NAME);
  4. intphoneId=cursor.getColumnIndex(People.NUMBER);}

删除

Java代码
  1. uri=ContentUris.withAppendedId(People.CONTENT_URI,联系人id);
  2. intcount=activity.getContentResolver().delete(uri,null,null);

添加到联系人:

Java代码
  1. ContentValuescv=newContentValues();
  2. ArrayList<ContentProviderOperation>operationList=newArrayList<ContentProviderOperation>();
  3. ContentProviderOperation.Builderbuilder=ContentProviderOperation.newInsert(RawContacts.CONTENT_URI);
  4. builder.withValues(cv);
  5. operationList.add(builder.build());
  6. builder=ContentProviderOperation.newInsert(Data.CONTENT_URI);
  7. builder.withValueBackReference(StructuredName.RAW_CONTACT_ID,0);
  8. builder.withValue(Data.MIMETYPE,StructuredName.CONTENT_ITEM_TYPE);
  9. builder.withValue(StructuredName.DISPLAY_NAME,"自定义联系人名");
  10. operationList.add(builder.build());
  11. builder=ContentProviderOperation.newInsert(Data.CONTENT_URI);
  12. builder.withValueBackReference(Phone.RAW_CONTACT_ID,0);
  13. builder.withValue(Data.MIMETYPE,Phone.CONTENT_ITEM_TYPE);
  14. builder.withValue(Phone.NUMBER,"联系人的phonenumber");
  15. builder.withValue(Data.IS_PRIMARY,1);
  16. operationList.add(builder.build());
  17. try{
  18. getContentResolver().applyBatch(ContactsContract.AUTHORITY,operationList);
  19. }catch(RemoteExceptione){
  20. e.printStackTrace();
  21. }catch(OperationApplicationExceptione){
  22. e.printStackTrace();
  23. }

动作 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搜索引擎

发送邮件:

Java代码
  1. Uriuri=Uri.parse("mailto:terryyhl@gmail.com");
  2. IntentMymailIntent=newIntent(Intent.ACTION_SEND,uri);
  3. startActivity(MymailIntent);

方法二:

Java代码
  1. Intenttestintent=newIntent(Intent.ACTION_SEND);
  2. String[]tos={"terryyhl@gmail.com"};
  3. String[]ccs={"kalaicheng@hotmail.com"};
  4. testintent.putExtra(Intent.EXTRA_EMAIL,tos);
  5. testintent.putExtra(Intent.EXTRA_CC,ccs);
  6. testintent.putExtra(Intent.EXTRA_TEXT,"这是内容");
  7. testintent.putExtra(Intent.EXTRA_SUBJECT,"这是标题");
  8. testintent.setType("message/rfc822");
  9. startActivity(Intent.createChooser(testintent,"发送"));

播放多媒体:

Java代码
  1. //播放多媒体
  2. Intentit=newIntent(Intent.ACTION_VIEW);
  3. Uriuri=Uri.parse("file:///sdcard/song.mp3");it.setDataAndType(uri,"audio/mp3");
  4. startActivity(it);
  5. Uriuri=Uri.withAppendedPath(MediaStore.Audio.Media.INTERNAL_CONTENT_URI,"1");
  6. Intentit=newIntent(Intent.ACTION_VIEW,uri);startActivity(it);

更多相关文章

  1. Android(安卓)百分比布局
  2. Android(安卓)支持的 media 文件格式--MediaFile
  3. Android之Input子系统事件分发流程
  4. Android(安卓)布局
  5. Eclipse+CDT+GDB调试android NDK程序 轉
  6. vlc android 代码编译
  7. Android(安卓)Pull解析xml
  8. android 导出签名APK--混淆文件proguard.cfg详解
  9. Google Android(安卓)应用程序结构

随机推荐

  1. Android(安卓)判断是否打开移动网络开关
  2. Android(安卓)Contacts(一)—— 读取联系人
  3. Android7.0中文文档(API)-- SimpleExpandab
  4. Android(安卓)Theme主题继承(SDK下主题和v
  5. android 自定义控件全系列导航
  6. Android控制文字水平间距android:letterS
  7. [置顶] Android(安卓)Studio编译
  8. Android(安卓)Studio导入第三方类库的方
  9. Android(安卓)应用开发推荐书单
  10. android 更新列表