Android Intent调用
Java代码:
//调用浏览器
Uriuri=Uri.parse("");
Intentit=newIntent(Intent.ACTION_VIEW,uri);
startActivity(it);
//显示某个坐标在地图上
Uriuri=Uri.parse("geo:38.899533,-77.036476");
Intentit=newIntent(Intent.Action_VIEW,uri);
startActivity(it);
//显示路径
Uriuri=Uri.parse("http://maps.google.com/maps?f=d&saddr=startLat%20startLng&daddr=endLat%20endLng&hl=en");
Intentit=newIntent(Intent.ACTION_VIEW,URI);
startActivity(it);
//拨打电话
Uriuri=Uri.parse("tel:10086");
Intentit=newIntent(Intent.ACTION_DIAL,uri);
startActivity(it);
Uriuri=Uri.parse("tel.10086");
Intentit=newIntent(Intent.ACTION_CALL,uri);
需要添加这个权限到androidmanifest.xml
//发送短信或彩信
Intentit=newIntent(Intent.ACTION_VIEW);
it.putExtra("sms_body","TheSMStext");
it.setType("vnd.android-dir/mms-sms");
startActivity(it);
//发送短信
Uriuri=Uri.parse("smsto:10086");
Intentit=newIntent(Intent.ACTION_SENDTO,uri);
it.putExtra("sms_body","cwj");
startActivity(it);
//发送彩信
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);
//发送邮件
Uriuri=Uri.parse("mailto:android123@163.com");
Intentit=newIntent(Intent.ACTION_SENDTO,uri);
startActivity(it);
Intentit=newIntent(Intent.ACTION_SEND);
it.putExtra(Intent.EXTRA_EMAIL,android123@163.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_VIEW);
Uriuri=Uri.parse("file:///sdcard/cwj.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);
//卸载APK
Uriuri=Uri.fromParts("package",strPackageName,null);
Intentit=newIntent(Intent.ACTION_DELETE,uri);
startActivity(it);
//卸载apk2
UriuninstallUri=Uri.fromParts("package","xxx",null);
returnIt=newIntent(Intent.ACTION_DELETE,uninstallUri);
//安装APK
UriinstallUri=Uri.fromParts("package","xxx",null);
returnIt=newIntent(Intent.ACTION_PACKAGE_ADDED,installUri);
//播放音乐
UriplayUri=Uri.parse("file:///sdcard/download/sth.mp3");
returnIt=newIntent(Intent.ACTION_VIEW,playUri);
//发送附近
Intentit=newIntent(Intent.ACTION_SEND);
it.putExtra(Intent.EXTRA_SUBJECT,"Theemailsubjecttext");
it.putExtra(Intent.EXTRA_STREAM,"file:///sdcard/cwj.mp3");
sendIntent.setType("audio/mp3");
startActivity(Intent.createChooser(it,"ChooseEmailClient"));
//market上某个应用信,pkg_name就是应用的packageName
Uriuri=Uri.parse("market://search?q=pname:pkg_name");
Intentit=newIntent(Intent.ACTION_VIEW,uri);
startActivity(it);
//market上某个应用信息,app_id可以通过www网站看下
Uriuri=Uri.parse("market://details?id=app_id");
Intentit=newIntent(Intent.ACTION_VIEW,uri);
startActivity(it);
//调用搜索
Intentintent=newIntent();
intent.setAction(Intent.ACTION_WEB_SEARCH);
intent.putExtra(SearchManager.QUERY,"android123");
startActivity(intent);
Java代码:
//调用浏览器
Uriuri=Uri.parse("");
Intentit=newIntent(Intent.ACTION_VIEW,uri);
startActivity(it);
//显示某个坐标在地图上
Uriuri=Uri.parse("geo:38.899533,-77.036476");
Intentit=newIntent(Intent.Action_VIEW,uri);
startActivity(it);
//显示路径
Uriuri=Uri.parse("http://maps.google.com/maps?f=d&saddr=startLat%20startLng&daddr=endLat%20endLng&hl=en");
Intentit=newIntent(Intent.ACTION_VIEW,URI);
startActivity(it);
//拨打电话
Uriuri=Uri.parse("tel:10086");
Intentit=newIntent(Intent.ACTION_DIAL,uri);
startActivity(it);
Uriuri=Uri.parse("tel.10086");
Intentit=newIntent(Intent.ACTION_CALL,uri);
需要添加这个权限到androidmanifest.xml
//发送短信或彩信
Intentit=newIntent(Intent.ACTION_VIEW);
it.putExtra("sms_body","TheSMStext");
it.setType("vnd.android-dir/mms-sms");
startActivity(it);
//发送短信
Uriuri=Uri.parse("smsto:10086");
Intentit=newIntent(Intent.ACTION_SENDTO,uri);
it.putExtra("sms_body","cwj");
startActivity(it);
//发送彩信
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);
//发送邮件
Uriuri=Uri.parse("mailto:android123@163.com");
Intentit=newIntent(Intent.ACTION_SENDTO,uri);
startActivity(it);
Intentit=newIntent(Intent.ACTION_SEND);
it.putExtra(Intent.EXTRA_EMAIL,android123@163.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_VIEW);
Uriuri=Uri.parse("file:///sdcard/cwj.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);
//卸载APK
Uriuri=Uri.fromParts("package",strPackageName,null);
Intentit=newIntent(Intent.ACTION_DELETE,uri);
startActivity(it);
//卸载apk2
UriuninstallUri=Uri.fromParts("package","xxx",null);
returnIt=newIntent(Intent.ACTION_DELETE,uninstallUri);
//安装APK
UriinstallUri=Uri.fromParts("package","xxx",null);
returnIt=newIntent(Intent.ACTION_PACKAGE_ADDED,installUri);
//播放音乐
UriplayUri=Uri.parse("file:///sdcard/download/sth.mp3");
returnIt=newIntent(Intent.ACTION_VIEW,playUri);
//发送附近
Intentit=newIntent(Intent.ACTION_SEND);
it.putExtra(Intent.EXTRA_SUBJECT,"Theemailsubjecttext");
it.putExtra(Intent.EXTRA_STREAM,"file:///sdcard/cwj.mp3");
sendIntent.setType("audio/mp3");
startActivity(Intent.createChooser(it,"ChooseEmailClient"));
//market上某个应用信,pkg_name就是应用的packageName
Uriuri=Uri.parse("market://search?q=pname:pkg_name");
Intentit=newIntent(Intent.ACTION_VIEW,uri);
startActivity(it);
//market上某个应用信息,app_id可以通过www网站看下
Uriuri=Uri.parse("market://details?id=app_id");
Intentit=newIntent(Intent.ACTION_VIEW,uri);
startActivity(it);
//调用搜索
Intentintent=newIntent();
intent.setAction(Intent.ACTION_WEB_SEARCH);
intent.putExtra(SearchManager.QUERY,"android123");
startActivity(intent);