zoukankan      html  css  js  c++  java
  • Android-看操作系统短信应用源码-隐式意图激活短信界面

     选择模拟器Unknown Google Nexus,在选择system_process(系统进程)

    操作模拟器的,操作系统短信应用,让操作系统短信打印日志,来查看:

     然后就找到来,操作系统短信应用打印的日志:

    然后打开操作系统短信源码进行查看,找到android-5.1.0操作系统源码/package/apps/Mms(短信应用)

    查看程序的入口AndroidManifest.xml文件,查找ComposeMessageActivity节点

    既然操作系统的短信--发短信界面已经通过intent-filter对外暴露了,只需选择某个intent-filter,任意匹配一组即可

    我就选择这个intent-filter来隐式意图激活:

          <intent-filter>
                    <action android:name="android.intent.action.VIEW" />
                    <action android:name="android.intent.action.SENDTO" />
                    <category android:name="android.intent.category.DEFAULT" />
                    <category android:name="android.intent.category.BROWSABLE" />
                    <data android:scheme="mms" />
                    <data android:scheme="mmsto" />
                </intent-filter>

    去隐式意图激活操作系统的Mms短信应用:

      /**
         * 打开操作系统短信应用-发短信界面
         * @param view
         */
        public void startMms(View view) {
            /**
             *            <intent-filter>
             *                 <action android:name="android.intent.action.VIEW" />
             *                 <action android:name="android.intent.action.SENDTO" />   匹配这一组就好来
             *                 <category android:name="android.intent.category.DEFAULT" />  匹配这一组就好来
             *                 <category android:name="android.intent.category.BROWSABLE" />
             *                 <data android:scheme="mms" /> 匹配这一组就好来
             *                 <data android:scheme="mmsto" />
             *             </intent-filter>
             */
            // 隐式意图激活,操作系统短信应用-发短信界面
            Intent intent = new Intent();
            intent.setAction("android.intent.action.SENDTO");
            // 在这里为什么不需要设置:category android:name="android.intent.category.DEFAULT",因为在startActivity会自动添加
            intent.setData(Uri.parse("mms:13787686565"));
            startActivity(intent);
        }

    效果:

     

  • 相关阅读:
    jvm参数陷阱
    concurrent mode failure
    17.Quick QML-SpinBox
    16.Quick QML-ButtonGroup、RadioButton、CheckBox
    15.Quick QML-TextEdit和TextArea
    14.Quick QML-TextInput和TextField详解
    13.Quick QML-RowLayout、ColumnLayout、GridLayout布局管理器介绍、并通过GridLayout设计的简易网站导航界面
    9.qml-property自定义属性
    macOS 系统安装Maven教程
    macOS系统上 为Github 托管项目的访问添加SSH keys
  • 原文地址:https://www.cnblogs.com/android-deli/p/10109115.html
Copyright © 2011-2022 走看看