Intent

Explicit Intent

  明确的意图,明确指定开启某个Activity。

  Intent intent = New Intent (this , 指定的Activity);

共享Intent

  把Intetn的动作类型设为 :Intent.ACTION_SEND

  即:Intent.setAction(Intent.ACTION_SEND).

//传入的参数Intent.ACTION_SENT 意为分享数据
Intent shareingintent = new Intent(Intent.ACTION_SEND);
 
//setType 设置分享的数据类型。可以指定为text/plain”、”image/jpeg”、”audio/mp4a-latm”、”audio/x-mpeg”、 “video/mp4“ 或者其他。
shareingintent.setType("text/plain");

 

Implicit Intent

<resources>
    <string-array name="intends" >
        <item>Open Browser</item>
        <item>Dial</item>
        <item>Show map</item>
        <item>Search On Map</item>
        <item>Take  Picture</item>
        <item>Show Contacts</item>
        <item>Edit first contact</item>
    </string-array>
</resources>
 Intent intent = null;
        switch (position){
            case 0:
                intent = new Intent(Intent.ACTION_VIEW,  //打开网站的意图
                        Uri.parse("http://www.vogella.com"));
                break;
            case 1:
                intent = new Intent(Intent.ACTION_DIAL,  //启动拨号盘的意图
                        Uri.parse("tel:(+49)132456789"));
                break;
            case  2:
                intent = new Intent(Intent.ACTION_VIEW,  //启动地图的意图
                        Uri.parse("geo:50.123,7.1434?z=19") );
                break;
            case 3:
                intent = new Intent(Intent.ACTION_VIEW, //启动地图并搜索给定位置名“西丽”的意图
                        Uri.parse("geo:0,0?q=西丽”));
                break;
            case 4:
                intent = new Intent("android.media.action.IMAGE_CAPTURE"); //启动相机的意图
                break;
            case 5:
                intent = new Intent(Intent.ACTION_VIEW, //启动联系人界面的意图
                        Uri.parse("content://contacts/people/"));
                break;西丽
            case 6:
                intent = new Intent(Intent.ACTION_EDIT,  //启动第一个联系人的意图
                        Uri.parse("content://contacts/people/1"));
                break;

        }

 

posted @ 2017-07-24 15:09  halo-漾  阅读(177)  评论(0编辑  收藏  举报