`
wang_peng1
  • 浏览: 3902081 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

intent方法使用总结

阅读更多
//show webapp:

Uri uri = Uri.parse("http://www.google.com");
Intent it  = new Intent(Intent.ACTION_VIEW,uri);
startActivity(it);

//show maps:
Uri uri = Uri.parse("geo:38.899533,-77.036476");
Intent it = new Intent(Intent.Action_VIEW,uri);
startActivity(it); 

//show ways
Uri uri = Uri.parse("http://maps.google.com/maps?f=d&saddr=startLat%20startLng&daddr=endLat%20endLng&hl=en");
Intent it = new Intent(Intent.ACTION_VIEW,URI);
startActivity(it);

//call dial program
Uri uri = Uri.parse("tel:xxxxxx");
Intent it = new Intent(Intent.ACTION_DIAL, uri);  
startActivity(it);  

Uri uri = Uri.parse("tel.xxxxxx");
Intent it =new Intent(Intent.ACTION_CALL,uri);
//don't forget add this config:<uses-permission id="android.permission.CALL_PHONE" />

//send sms/mms
//call sender program
Intent it = new Intent(Intent.ACTION_VIEW);   
it.putExtra("sms_body", "The SMS text");   
it.setType("vnd.android-dir/mms-sms");   
startActivity(it);  

//send sms
Uri uri = Uri.parse("smsto:0800000123");   
Intent it = new Intent(Intent.ACTION_SENDTO, uri);   
it.putExtra("sms_body", "The SMS text");   
startActivity(it);  

//send mms
Uri uri = Uri.parse("content://media/external/images/media/23");   
Intent it = new Intent(Intent.ACTION_SEND);   
it.putExtra("sms_body", "some text");   
it.putExtra(Intent.EXTRA_STREAM, uri);   
it.setType("image/png");   
startActivity(it); 

//send email
 
Uri uri = Uri.parse("mailto:xxx@abc.com");
Intent it = new Intent(Intent.ACTION_SENDTO, uri);
startActivity(it);

Intent it = new Intent(Intent.ACTION_SEND);   
it.putExtra(Intent.EXTRA_EMAIL, "me@abc.com");   
it.putExtra(Intent.EXTRA_TEXT, "The email body text");   
it.setType("text/plain");   
startActivity(Intent.createChooser(it, "Choose Email Client"));  

Intent it=new Intent(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, "The email body text");     
it.putExtra(Intent.EXTRA_SUBJECT, "The email subject text");     
it.setType("message/rfc822");     
startActivity(Intent.createChooser(it, "Choose Email Client"));   


//add extra
Intent it = new Intent(Intent.ACTION_SEND);   
it.putExtra(Intent.EXTRA_SUBJECT, "The email subject text");   
it.putExtra(Intent.EXTRA_STREAM, "file:///sdcard/mysong.mp3");   
sendIntent.setType("audio/mp3");   
startActivity(Intent.createChooser(it, "Choose Email Client"));

//play media
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);  

//Uninstall
Uri uri = Uri.fromParts("package", strPackageName, null);   
Intent it = new Intent(Intent.ACTION_DELETE, uri);   
startActivity(it);

//uninstall apk
Uri uninstallUri = Uri.fromParts("package", "xxx", null);
returnIt = new Intent(Intent.ACTION_DELETE, uninstallUri);

//install apk
Uri installUri = Uri.fromParts("package", "xxx", null);
returnIt = new Intent(Intent.ACTION_PACKAGE_ADDED, installUri);

//play audio
Uri playUri = Uri.parse("file:///sdcard/download/everything.mp3");
returnIt = new Intent(Intent.ACTION_VIEW, playUri);

//send extra
Intent it = new Intent(Intent.ACTION_SEND);  
it.putExtra(Intent.EXTRA_SUBJECT, "The email subject text");  
it.putExtra(Intent.EXTRA_STREAM, "file:///sdcard/eoe.mp3");  
sendIntent.setType("audio/mp3");  
startActivity(Intent.createChooser(it, "Choose Email Client"));

//search
Uri uri = Uri.parse("market://search?q=pname:pkg_name");  
Intent it = new Intent(Intent.ACTION_VIEW, uri);  
startActivity(it);  
//where pkg_name is the full package path for an application  

//show program detail page
Uri uri = Uri.parse("market://details?id=app_id");  
Intent it = new Intent(Intent.ACTION_VIEW, uri);  
startActivity(it);  
//where app_id is the application ID, find the ID  
//by clicking on your application on Market home  
//page, and notice the ID from the address bar


//search google
Intent intent = new Intent();
intent.setAction(Intent.ACTION_WEB_SEARCH);
intent.putExtra(SearchManager.QUERY,"searchString")
startActivity(intent);

 

分享到:
评论

相关推荐

    Android开发课程实验报告③ intent的使用

    初学移动应用公开发中的Android开发,实验四的主要内容为intent的使用,通过这一次实验,掌握基本的intent使用方法。 具体实验分析 实验第一步:阅读官方文档:intent 实验解析:本次实验共分为两个部分。第一个部分...

    Android的Intent实验

    通过一个实验,讲解Android的使用方法,总结详细

    Android Intent调用 Uri的方法总结

    Android Intent调用 Uri的方法总结 //调用浏览器 Uri uri = Uri.parse(); Intent it = new Intent(Intent.ACTION_VIEW,uri); startActivity(it); //显示某个坐标在地图上 Uri uri = Uri.parse(geo:38.899533,-...

    谈谈安卓的Intent注入.pdf

    归纳了利用自动化的工具具发现这4类形式的方法,通过批 量的扫描,可以轻易发现这些漏洞 在每种都找到了一个安卓OS或Chrome安卓版的0day,达 到本地提权或远程命令执行的效果,分别得到了Android 与Chrome的官方致谢

    Android开发中Intent用法总结

    主要介绍了Android开发中Intent用法,总结分析了Android中Intent的功能、使用方法与相关注意事项,需要的朋友可以参考下

    Android实现打开各种文件的intent方法小结

    主要介绍了Android实现打开各种文件的intent方法,结合实例形式总结分析了Android针对HTML、图片文件、pdf文件、文本文件、音频文件、视频文件等的intent打开方法,需要的朋友可以参考下

    Android 调用系统应用的方法总结

    Android 调用系统应用的方法总结 1、调用系统拍照 Intent intent = new Intent(android.media.action.IMAGE_CAPTURE); //保存到指定目录 File file = new File&#40;/mnt/sdcard/picture&#41;; if (!file.exists()...

    Android 启动第三方程序的方法总结

    Android 启动第三方程序的方法总结 方法一: Intent intent = new Intent(); intent.setClassName(, ); startActivity(intent); 方法二: Intent i=new Intent; ComponentName com= new ComponentName...

    Android Activity之间的数据传递方法总结

    基本数据类型、复杂数据类型(如数组、集合)、自定义数据类型等等都能支持,而且使用起来也不复杂。下面将通过几个小栗子分别介绍一下这几种方法。 1.1、基本数据类型传递 String 不是基本数据类型,

    西工大安卓大作业-日记本(源码+实验报告+问题总结)

    里面有set和get方法。 NoteAdapter类继承了ArrayAdapter,相当于是Note数组对象的适配器,用来包装Note数据,很好地实现数据和界面分离。 AddNewDiary这个类用于新建一则日记,使用add_new_diary.xml界面,这里没有...

    Activity基础知识总结

    文档通过代码实践总结了Activity的生命周期方法,Launcher Mode启动方式,Intent Filter的匹配规则。同时文档中用截图记录关键的Log信息。文件中也包含了代码可以方便的学习和理解Activity。

    Android开发指南中文版

    使用意图匹配Using intent matching 52 数据存储Data Storage 52 概览Storage quickview 52  系统偏好:快速,轻量级存储 52  文件:存储到设备内部或可移动闪存 52  数据库:任意的结构化存储 52  支持基于...

    Android开发宝典.rar

    使用意图匹配Using intent matching 52 数据存储Data Storage 52 概览Storage quickview 52  系统偏好:快速,轻量级存储 52  文件:存储到设备内部或可移动闪存 52  数据库:任意的结构化存储 52  ...

    Android四大组件知识点总结

    Intent是信使,负责完成Android四大组件之间的信息传递,同类、不同类的组件无法直接传递对象,一旦需要沟通只能通过Intent(不建议通过静态变量或静态方法传递数据,容易造成数据异常、内存泄露等问题)。...

    Android开发指南中文版-----应用程序框架

    使用意图匹配Using intent matching 52 数据存储Data Storage 52 概览Storage quickview 52 ? 系统偏好:快速,轻量级存储 52 ? 文件:存储到设备内部或可移动闪存 52 ? 数据库:任意的结构化存储 52 ? 支持基于网络...

    Android开发技巧总汇(个人总结)

    目录 1.坐标传递到google ...★44.intent action大全: 53 ★45.Android的动作、广播、类别等标志大全 54 ★★★46.附带工具包说明 60 1.APK反编译工具.rar 60 2.APK安装工具.rar 60 47.Google Maps 的应用 60

    Android源码铃声汇总

    最近研究源码程序,改了改手机短信铃声的源码,最近总结了下铃声的代码,写个activity继承PreferenceActivity有:手机短信铃声,手机铃声,闹钟铃声,还有sdcard中的铃声,通过选择相应的铃声,然后读取到xml文件...

Global site tag (gtag.js) - Google Analytics