`
wang_peng1
  • 浏览: 3958995 次
  • 性别: 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 使用总结 Android Intent 是 Android 组件之间通讯的核心机制,它负责对应用中一次操作的动作、动作涉及数据、附加数据进行描述。Android 则根据 Intent 的描述,找到对应的组件,将 Intent 传递给...

    Android中intent的使用

    本篇文章将深入探讨Intent的基本概念、类型、构造方法以及如何在Android中有效地使用Intent。 Intent是一种意图声明,表达了应用程序想要执行的操作。在Android系统中,Intent分为显式Intent和隐式Intent两种类型。...

    Intent总结04 Data和Type属性

    Intent分为显式Intent和隐式Intent,而"Intent总结04 Data和Type属性"主要聚焦于Intent的数据(data)和类型(type)两个关键属性,它们在创建Intent时发挥着至关重要的作用。 1. **Intent的数据(data)**: Intent的数据...

    Intent使用示例(一)

    在标题提到的“Intent使用示例(一)”中,我们将重点关注`startActivityForResult`方法。这个方法通常用于启动一个Activity,并期望在新Activity执行完某些操作后返回结果。当用户在新Activity中完成任务,如选择照片...

    intent总结代码

    下面是对Intent的详细总结: 1. **Intent的基本类型** - 显式Intent:指定要启动的具体组件(Activity或Service),通过类名或组件的ComponentName来明确指定。 - 隐式Intent:不指定具体组件,而是定义一个行动...

    intent匹配规则大总结

    - 要指定完整的Data(包括Type和具体的URI),必须使用 `setDataAndType()` 方法,避免先后调用 `setData()` 和 `setType()` 导致值被覆盖。 10. **Scheme 的匹配**: - Scheme的匹配规则也需要遵循Intent与`...

    Intent总结03 Action属性

    发送Intent时,可以使用`startActivity(intent)`或`startService(intent)`方法。而接收方则需要在onCreate()或onStartCommand()方法中处理Intent,通过`intent.getAction()`获取Action并进行相应操作。 七、Intent ...

    使用Intent打开网页

    总结,使用Intent打开网页是Android开发中的常见操作,既可以调用系统浏览器实现跨应用的浏览,也可以借助WebView在应用内部加载网页。选择哪种方式取决于应用场景,如需保持用户在应用内的体验,WebView是理想选择...

    android中intent使用示例

    总结,Intent是Android系统中连接各个组件的桥梁,理解并熟练使用Intent对于开发Android应用至关重要。在实际项目中,Intent不仅可以用于启动Activity和Service,还可以用于启动BroadcastReceiver,实现各种组件间的...

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

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

    android Intent的用法

    总结,Intent在Android开发中扮演着至关重要的角色,无论是启动组件、传递数据还是实现组件间的通信,都离不开Intent的使用。理解和熟练掌握Intent的用法,是成为一名合格的Android开发者的基础。通过不断地实践和...

    Android中Intent的使用

    创建Intent通常使用以下构造方法: - `Intent(Context packageContext, Class&lt;?&gt; cls)`: 创建显式Intent,传入上下文和目标组件的Class。 - `Intent(String action)`: 创建隐式Intent,只设置Action。 - `Intent...

    Intent系统调用示例

    - 启动Activity:通过`startActivity(Intent)`方法启动Activity,Intent中可以携带数据。 - 启动Service:使用`startService(Intent)`或`bindService(Intent, ServiceConnection, int)`启动或绑定Service。 - ...

    Intent的多种用法

    总结来说,Intent是Android系统中的核心组成部分,它的多种用法包括显式和隐式Intent的创建、Intent Filter的定义、数据的传递以及调用系统服务和第三方应用。熟练掌握Intent的使用,将有助于提升Android应用的交互...

    Intent用法举例

    本文将深入讲解Intent在广播和服务中的使用方法,以实例的形式帮助开发者更好地理解Intent的用法。 一、Intent的基本概念 Intent在Android中扮演着消息传递者的角色,它封装了操作类型和数据,并在组件之间传递。...

    Android中使用Intent获取其他应用程序信息的方法介绍.pdf

    首先,定义一个方法获取文件的MIME类型,然后创建一个Intent,设置ACTION_VIEW动作,使用getDataAndType()方法设置文件Uri和其MIME类型,最后启动Intent。 ```java private void openFile(File f) { Intent intent...

    Intent总结02 component和显式意图

    通过调用`putExtra()`方法,可以在Intent中添加额外的数据,这些数据可以在目标组件中通过`getExtra()`方法获取。这可以是各种类型的数据,如字符串、整数、浮点数、布尔值,甚至是自定义对象。 4. **启动组件** ...

    Intent总结

    以上就是关于Intent的全面总结,它是Android框架中的关键部分,熟练掌握Intent的使用对于构建功能丰富的Android应用至关重要。通过深入理解Intent的各个组件和功能,开发者能够更好地控制应用的流程和交互。

    intent的深入分析

    2. 启动Service:使用startService()或bindService(),配合Service的相关生命周期方法。 3. 发送Broadcast:使用sendBroadcast()、sendOrderedBroadcast()或send StickyBroadcast(),广播接收器通过onReceive()接收...

    Android使用Intent实现Video功能

    本文将详细探讨如何使用Intent来实现Android中的Video功能。 首先,我们要理解Android的MediaStore类。MediaStore是Android系统提供的一个数据库,它包含了设备上的所有媒体文件,包括图片、音频和视频。通过...

Global site tag (gtag.js) - Google Analytics