- 1.从google搜索内容
- Intentintent=newIntent();
- intent.setAction(Intent.ACTION_WEB_SEARCH);
- intent.putExtra(SearchManager.QUERY,"searchString")
- startActivity(intent);
- 2.浏览网页
- Uriuri=Uri.parse("http://www.google.com");
- Intentit=newIntent(Intent.ACTION_VIEW,uri);
- startActivity(it);
- 3.显示地图
- Uriuri=Uri.parse("geo:38.899533,-77.036476");
- Intentit=newIntent(Intent.Action_VIEW,uri);
- startActivity(it);
- 4.路径规划
- Uriuri=Uri.parse("http://maps.google.com/maps?f=dsaddr=startLatstartLng&daddr=endLatendLng&hl=en");
- Intentit=newIntent(Intent.ACTION_VIEW,URI);
- startActivity(it);
- 5.拨打电话
- Uriuri=Uri.parse("tel:xxxxxx");
- Intentit=newIntent(Intent.ACTION_DIAL,uri);
- startActivity(it);
- 6.调用发短信的程序
- Intentit=newIntent(Intent.ACTION_VIEW);
- it.putExtra("sms_body","TheSMStext");
- it.setType("vnd.android-dir/mms-sms");
- startActivity(it);
- 7.发送短信
- Uriuri=Uri.parse("smsto:0800000123");
- Intentit=newIntent(Intent.ACTION_SENDTO,uri);
- it.putExtra("sms_body","TheSMStext");
- startActivity(it);
- Stringbody="thisissmsdemo";
- Intentmmsintent=newIntent(Intent.ACTION_SENDTO,Uri.fromParts("smsto",number,null));
- mmsintent.putExtra(Messaging.KEY_ACTION_SENDTO_MESSAGE_BODY,body);
- mmsintent.putExtra(Messaging.KEY_ACTION_SENDTO_COMPOSE_MODE,true);
- mmsintent.putExtra(Messaging.KEY_ACTION_SENDTO_EXIT_ON_SENT,true);
- startActivity(mmsintent);
- 8.发送彩信
- Uriuri=Uri.parse("content://media/external/images/media/23");
- Intentit=newIntent(Intent.ACTION_SEND);
- it.putExtra("sms_body","sometext");
- it.putExtra(Intent.EXTRA_STREAM,uri);
- it.setType("image/png");
- startActivity(it);
- StringBuildersb=newStringBuilder();
- sb.append("file://");
- sb.append(fd.getAbsoluteFile());
- Intentintent=newIntent(Intent.ACTION_SENDTO,Uri.fromParts("mmsto",number,null));
- //Belowextradatasarealloptional.
- intent.putExtra(Messaging.KEY_ACTION_SENDTO_MESSAGE_SUBJECT,subject);
- intent.putExtra(Messaging.KEY_ACTION_SENDTO_MESSAGE_BODY,body);
- intent.putExtra(Messaging.KEY_ACTION_SENDTO_CONTENT_URI,sb.toString());
- intent.putExtra(Messaging.KEY_ACTION_SENDTO_COMPOSE_MODE,composeMode);
- intent.putExtra(Messaging.KEY_ACTION_SENDTO_EXIT_ON_SENT,exitOnSent);
- startActivity(intent);
- 9.发送Email
- Uriuri=Uri.parse("mailto:xxx@abc.com");
- Intentit=newIntent(Intent.ACTION_SENDTO,uri);
- startActivity(it);
- Intentit=newIntent(Intent.ACTION_SEND);
- it.putExtra(Intent.EXTRA_EMAIL,"me@abc.com");
- it.putExtra(Intent.EXTRA_TEXT,"Theemailbodytext");
- it.setType("text/plain");
- startActivity(Intent.createChooser(it,"ChooseEmailClient"));
- Intentit=newIntent(Intent.ACTION_SEND);
- String[]tos={"me@abc.com"};
- String[]ccs={"you@abc.com"};
- it.putExtra(Intent.EXTRA_EMAIL,tos);
- it.putExtra(Intent.EXTRA_CC,ccs);
- it.putExtra(Intent.EXTRA_TEXT,"Theemailbodytext");
- it.putExtra(Intent.EXTRA_SUBJECT,"Theemailsubjecttext");
- it.setType("message/rfc822");
- startActivity(Intent.createChooser(it,"ChooseEmailClient"));
- Intentit=newIntent(Intent.ACTION_SEND);
- it.putExtra(Intent.EXTRA_SUBJECT,"Theemailsubjecttext");
- it.putExtra(Intent.EXTRA_STREAM,"file:///sdcard/mysong.mp3");
- sendIntent.setType("audio/mp3");
- startActivity(Intent.createChooser(it,"ChooseEmailClient"));
- 10.播放多媒体
- Intentit=newIntent(Intent.ACTION_VIEW);
- Uriuri=Uri.parse("file:///sdcard/song.mp3");
- it.setDataAndType(uri,"audio/mp3");
- startActivity(it);
- Uriuri=Uri.withAppendedPath(MediaStore.Audio.Media.INTERNAL_CONTENT_URI,"1");
- Intentit=newIntent(Intent.ACTION_VIEW,uri);
- startActivity(it);
- 11.卸载apk
- Uriuri=Uri.fromParts("package",strPackageName,null);
- Intentit=newIntent(Intent.ACTION_DELETE,uri);
- startActivity(it);
- 12.安装apk
- UriinstallUri=Uri.fromParts("package","xxx",null);
- returnIt=newIntent(Intent.ACTION_PACKAGE_ADDED,installUri);
Android Intent应用,打开网页,安装程序,打电话,打开地图等功能
最新推荐文章于 2021-05-27 14:28:38 发布