`

android intent和intent action大全

 
阅读更多

 

android intent是经常要用到的。不管是页面牵转还是传递数据或是调用外部程序系统功能都要用到intent。在做了一些intent的例子之后,整理了一下intent,希望对大家有用。由于intent内容太多,不可能真的写全,难免会有遗落,以后我会随时更新。如果你们有疑问或新的intent内容,希望交流。 

intent大全: 
1.
google搜索内容 
Intent intent = new Intent(); 
intent.setAction(Intent.ACTION_WEB_SEARCH); 
intent.putExtra(SearchManager.QUERY,"searchString") 
startActivity(intent); 

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

3.
显示地图 
Uri uri = Uri.parse("geo:38.899533,-77.036476"); 
Intent it = new Intent(Intent.Action_VIEW,uri); 
startActivity(it); 

4.
路径规划 
Uri uri = Uri.parse("http://maps.google.com/maps?f=dsaddr=startLat%20startLng&daddr=endLat%20endLng&hl=en"); 
Intent it = new Intent(Intent.ACTION_VIEW,URI); 
startActivity(it); 

5.
拨打电话 
Uri uri = Uri.parse("tel:xxxxxx"); 
Intent it = new Intent(Intent.ACTION_DIAL, uri);   
startActivity(it); 

6.
调用发短信的程序 
Intent it = new Intent(Intent.ACTION_VIEW);    
it.putExtra("sms_body", "The SMS text");    
it.setType("vnd.android-dir/mms-sms");    
startActivity(it); 

7.
发送短信 
Uri uri = Uri.parse("smsto:0800000123");    
Intent it = new Intent(Intent.ACTION_SENDTO, uri);    
it.putExtra("sms_body", "The SMS text");    
startActivity(it); 
String body="this is sms demo"; 
Intent mmsintent = new Intent(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.
发送彩信 
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); 
StringBuilder sb = new StringBuilder(); 
sb.append("file://"); 
sb.append(fd.getAbsoluteFile()); 
Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mmsto", number, null)); 
// Below extra datas are all optional. 
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 
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"));    

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")); 

10.
播放多媒体   
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); 

11.uninstall apk 
Uri uri = Uri.fromParts("package", strPackageName, null);    
Intent it = new Intent(Intent.ACTION_DELETE, uri);    
startActivity(it); 

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

13.
打开照相机 
    <1>Intent i = new Intent(Intent.ACTION_CAMERA_BUTTON, null); 
           this.sendBroadcast(i); 
     <2>long dateTaken = System.currentTimeMillis(); 
            String name = createName(dateTaken) + ".jpg"; 
            fileName = folder + name; 
            ContentValues values = new ContentValues(); 
            values.put(Images.Media.TITLE, fileName); 
            values.put("_data", fileName); 
            values.put(Images.Media.PICASA_ID, fileName); 
            values.put(Images.Media.DISPLAY_NAME, fileName); 
            values.put(Images.Media.DESCRIPTION, fileName); 
            values.put(Images.ImageColumns.BUCKET_DISPLAY_NAME, fileName); 
            Uri photoUri = getContentResolver().insert( 
                    MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values); 
             
            Intent inttPhoto = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); 
            inttPhoto.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); 
            startActivityForResult(inttPhoto, 10); 

14.
gallery选取图片 
  Intent i = new Intent(); 
            i.setType("image/*"); 
            i.setAction(Intent.ACTION_GET_CONTENT); 
            startActivityForResult(i, 11); 

15.
打开录音机 
   Intent mi = new Intent(Media.RECORD_SOUND_ACTION); 
            startActivity(mi); 

16.
显示应用详细列表       
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      

刚才找app id未果,结果发现用package name也可以 
Uri uri = Uri.parse("market://details?id=<packagename>"); 
这个简单多了 

17
寻找应用       
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       

18
打开联系人列表 
            <1>            
           Intent i = new Intent(); 
           i.setAction(Intent.ACTION_GET_CONTENT); 
           i.setType("vnd.android.cursor.item/phone"); 
           startActivityForResult(i, REQUEST_TEXT); 

            <2> 
            Uri uri = Uri.parse("content://contacts/people"); 
            Intent it = new Intent(Intent.ACTION_PICK, uri); 
            startActivityForResult(it, REQUEST_TEXT); 

19
打开另一程序 
Intent i = new Intent(); 
            ComponentName cn = new ComponentName("com.yellowbook.android2", 
                    "com.yellowbook.android2.AndroidSearch"); 
            i.setComponent(cn); 
            i.setAction("android.intent.action.MAIN"); 
            startActivityForResult(i, RESULT_OK); 

intent action大全: 

 

1. android.intent.action.ALL_APPS 

2. android.intent.action.ANSWER 

3. android.intent.action.ATTACH_DATA 

4. android.intent.action.BUG_REPORT 

5. android.intent.action.CALL 

6. android.intent.action.CALL_BUTTON 

7. android.intent.action.CHOOSER 

8. android.intent.action.CREATE_LIVE_FOLDER 

9. android.intent.action.CREATE_SHORTCUT 

10. android.intent.action.DELETE 

11. android.intent.action.DIAL 

12. android.intent.action.EDIT 

13. android.intent.action.GET_CONTENT 

14. android.intent.action.INSERT 

15. android.intent.action.INSERT_OR_EDIT 

16. android.intent.action.MAIN 

17. android.intent.action.MEDIA_SEARCH 

18. android.intent.action.PICK 

19. android.intent.action.PICK_ACTIVITY 

20. android.intent.action.RINGTONE_PICKER 

21. android.intent.action.RUN 

22. android.intent.action.SEARCH 

23. android.intent.action.SEARCH_LONG_PRESS 

24. android.intent.action.SEND 

25. android.intent.action.SENDTO 

26. android.intent.action.SET_WALLPAPER 

27. android.intent.action.SYNC 

28. android.intent.action.SYSTEM_TUTORIAL 

29. android.intent.action.VIEW 

30. android.intent.action.VOICE_COMMAND 

31. android.intent.action.WEB_SEARCH 

32. android.net.wifi.PICK_WIFI_NETWORK 

33. android.settings.AIRPLANE_MODE_SETTINGS 

34. android.settings.APN_SETTINGS 

35. android.settings.APPLICATION_DEVELOPMENT_SETTINGS 

36. android.settings.APPLICATION_SETTINGS 

37. android.settings.BLUETOOTH_SETTINGS 

38. android.settings.DATA_ROAMING_SETTINGS 

39. android.settings.DATE_SETTINGS 

40. android.settings.DISPLAY_SETTINGS 

41. android.settings.INPUT_METHOD_SETTINGS 

42. android.settings.INTERNAL_STORAGE_SETTINGS 

43. android.settings.LOCALE_SETTINGS 

44. android.settings.LOCATION_SOURCE_SETTINGS 

45. android.settings.MANAGE_APPLICATIONS_SETTINGS 

46. android.settings.MEMORY_CARD_SETTINGS 

47. android.settings.NETWORK_OPERATOR_SETTINGS 

48. android.settings.QUICK_LAUNCH_SETTINGS 

49. android.settings.SECURITY_SETTINGS 

50. android.settings.SETTINGS 

51. android.settings.SOUND_SETTINGS 

52. android.settings.SYNC_SETTINGS 

53. android.settings.USER_DICTIONARY_SETTINGS 

54. android.settings.WIFI_IP_SETTINGS 

55. android.settings.WIFI_SETTINGS 

56. android.settings.WIRELESS_SETTINGS 

 

转载自:http://www.ophonesdn.com/forum/thread-2609-1-1.html

 

分享到:
评论

相关推荐

    android intent和intent action大全.doc

    路径规划可以使用类似的方法,但需要构造一个包含起始和终点的URL,然后传递给`ACTION_VIEW`的Intent。 ```java Uri uri = Uri.parse(...

    android-intent-and-intent-action.zip_Android Intent_action

    android intent和intent action大全

    Android 广播大全 Intent Action 事件.

    Android 广播大全 Intent Action 事件是 Android 系统中的一种核心机制,用于在应用程序之间传递信息和事件通知。 Intent 是一种轻量级的消息对象,用于描述一个操作的请求或描述一个事件。 以下是 Android 广播...

    android_intent和intent_action大全

    在Android开发中,Intent是一种非常重要的机制,用于在应用程序组件之间进行通信,它可以用来启动其他组件,如Activity、...在开发过程中,合理使用Intent和IntentAction可以极大地提高应用程序的功能性和用户体验。

    android.intent.action.TIME_TICK

    3. 注册IntentFilter:为IntentFilter添加对应的ACTION,如"android.intent.action.TIME_TICK"、"android.intent.action.SCREEN_ON"和"android.intent.action.BATTERY_CHANGED"。 4. 不再需要时,记得在合适的位置...

    Android利用Intent启动和关闭Activity

    【Android Intent 启动和关闭Activity】 在Android应用程序开发中,Intent是连接各个组件(如Activity、Service等)的关键桥梁,主要用于启动和关闭Activity。Intent不仅能够启动一个新的Activity,还能在Activity...

    Android的Intent实验

    - `new Intent(context, action)`: 结合上下文和动作创建Intent。 3. **Intent的分类** - 显式Intent: 直接指定目标组件,适用于在同一应用内的组件间通信。 - 隐式Intent: 不指定目标组件,而是通过动作和数据...

    Android Intent用法大全

    ### Android Intent用法大全 #### 概述 在Android开发中,`Intent`是一个非常重要的概念,它主要用于组件之间的通信,比如启动一个Activity、服务、广播接收器等。本篇文章将详细介绍Intent的各种常见用法,包括但...

    android Action call 拨打电话 Intent.ACTION.CALL

    需要注意的是,从Android 10(API级别29)开始,ACTION_CALL Intent被限制在系统应用和已知可信的通话应用中使用,这意味着第三方应用通常不能直接拨打电话,除非用户明确设置该应用为默认通话应用。 在实际应用中...

    Android Intent切换.zip

    总结一下,"Android Intent切换.zip"包含的资料提供了关于Intent使用的实例,这对于理解和掌握Android中组件间的交互至关重要。通过研究源码,开发者可以学习到如何正确构建和使用Intent,以及如何在不同组件间传递...

    Intent.action_大全

    ### Android Intent Action 大全 #### 一、概述 在Android开发中,`Intent`作为组件间通信的重要机制之一,其通过携带特定的信息在不同组件之间进行传递,从而实现组件间的交互与通信。`Intent`有两种类型:显式...

    android Intent实例

    ### Android Intent 实例详解 #### 一、引言 在Android开发中,`Intent`扮演着极其重要的角色,它是应用程序内部以及不同应用程序之间通信的主要方式之一。通过`Intent`,开发者能够实现各种功能,比如打开网页、...

    Android Intent Filter用法

    &lt;action android:name="android.intent.action.SEND"/&gt; &lt;category android:name="android.intent.category.DEFAULT"/&gt; &lt;data android:mimeType="text/plain"/&gt; &lt;/intent-filter&gt; ``` 这段代码表示该组件可以处理...

    android intent 的生命周期讲解和历程

    而隐式Intent则不指定具体组件,而是根据Intent中的Action、Data、Category等信息匹配能够处理该Intent的组件。 接下来,我们关注Intent在Activity生命周期中的作用。当一个Intent被用来启动一个新的Activity时,它...

    android用于打开各种文件的intent.pdf

    在上面的代码中,我们首先创建了一个 Intent 对象,并指定了动作为 "android.intent.action.VIEW",然后使用 setDataAndType 方法设置了 URI 和类型为 "application/pdf",最后使用 startActivity 方法启动该 Intent...

    android用于打开各种文件的intent

    ”、“Intent it = getExcelFileIntent("/mnt/sdcard/Book1.xls")”和“Intent it = getPptFileIntent("/mnt/sdcard/download/Android_PPT.ppt");”这些代码片段展示了如何创建Intent来打开存储在系统或SD卡上的Word...

    android intent 使用总结

    Android Intent 使用总结 Android Intent 是 Android 组件之间通讯的核心机制,它负责对应用...Android Intent 是 Android 组件之间通讯的核心机制,理解 Intent 的工作机制和匹配规则是开发 Android 应用程序的关键。

Global site tag (gtag.js) - Google Analytics