• [android] 隐式意图的配置


    ndroid里面的清单文件相当于windows上的注册表,例如播放器可以关联文件直接打开,清单文件中activity节点的intent-filter节点进行配置

    添加<action/>动作节点,设置名称android:name=”com.xxx.xx.xx”

    添加<category/>默认附加选项节点,设置名称android:name=”android.intent.action.DEFAULT”

    添加<data/>数据节点,

    设置协议规范android:scheme=”http”

    设置主机名 android:host=”www.baidu.com”

    设置数据类型android:mimeType=”vnd.android.cursor.item/haha”

    测试一下这个隐式意图的配置

    获取Intent对象,通过new出来

    调用Intent对象的setAction(action)方法,参数:String对象 上面例如:”com.xxx.xx.xx”

    调用Intent对象的addCategory(category)方法,设置前提条件,参数:和上面的配置对应

    调用intent对象的setData(Uri)方法,设置数据,参数:Uri对象 Uri.parse(“http://xxx”)

    调用Intent对象的setType()方法,设置数据类型,参数:和上面配置对应,此方法和setData()不能共存

    解决,调用Intent对象的setDataAndType(data,type)方法,呵呵

    调用startActivity()

    跳转后的第二个activity里面获取数据

    获取到Intent对象,调用getIntent()方法

    调用Intent对象的getData()方法,获取到Uri对象

    调用Uri对象的toString()方法,打印出来看看

  • 相关阅读:
    android 单位详解
    ViewFlipper的使用
    today is history,today is tomorrow
    Android2.1 和之后的版本 中的 drawable(hdpi,ldpi,mdpi) 的区别
    auto_ptr
    android编写Service入门
    Android程序完全退出的三种方法
    Android中Toast的用法简介
    安装android开发环境
    error C2850: 'PCH header file'
  • 原文地址:https://www.cnblogs.com/taoshihan/p/5313235.html
Copyright © 2020-2023  润新知