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

    效果:

     

  • 相关阅读:
    Visual Studio使用技巧
    排颜色问题——数组 leetcode lintcode
    【简洁】微信为何总令人感觉如此简洁、?(一)
    字符串通信协议解析函数
    我所改造的JSocket适用于任何DELPHI版本
    缓存和字符串相互转换
    TcxDBTreeList导出EXCEL
    TcxGrid导出EXCEL
    TdxAlertWindowManager右下角HINT显示控件
    好用的编辑框布局控件TdxLayoutControl
  • 原文地址:https://www.cnblogs.com/android-deli/p/10109115.html
Copyright © 2011-2022 走看看