对于一些比较大型的项目,业务中可能会有其他APP的入口。一般分为两种:1.项目中内嵌一个友商的SDK(集成了部分业务的SDK)    2.唤醒友商的SDK(主要是已经安装的app),今天主要说下唤醒吧。

1.使用Intent,通过包名.类型进行唤醒:

被唤起的APP的类在manifest.xml的配置:

<activity android:name=".MyTestActivity1"  android:exported="true"><intent-filter><action android:name="android.intent.action.MAIN" /><action android:name="android.intent.action.VIEW"/><category android:name="android.intent.category.LAUNCHER" /></intent-filter></activity>

唤醒启动:com.example.myapplication1为包名,com.example.myapplication1.MyTestActivity1 包名.类名

Intent intent = new Intent();
intent.setComponent(new ComponentName("com.example.myapplication1","com.example.myapplication1.MyTestActivity1"));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);

2.通过intent使用Uri唤醒:

<activity android:name=".TestActivity3"  android:exported="true"><intent-filter> <action android:name="test.action" /><category android:name="android.intent.category.DEFAULT" />    <dataandroid:host="test.uri.activity"android:scheme="app" /></intent-filter>
</activity>

启动:

Uri uri = Uri.parse("app://test.uri.activity?id=1");
Intent intent2 = new Intent("test.action");
intent2.setData(uri);
startActivity(intent2);

被唤醒的页面获取Uri传递过来的参数:

if (null != intent) {Uri uri = intent.getData();if (uri == null) {return;}String TAG = "TAG";if (uri != null) {// 完整的url信息String url = uri.toString();Log.e(TAG, "url: " + url);// scheme部分String scheme = uri.getScheme();Log.e(TAG, "scheme: " + scheme);// host部分String host = uri.getHost();Log.e(TAG, "host: " + host);String data = uri.getQueryParameter("id");Toast.makeText(this, data, Toast.LENGTH_SHORT).show();}}

3.H5网页浏览器唤醒:

1.先写一个web小项目,有网页就行如下图所示,并且部署到tomcat:

在浏览器上打开此链接便是:

咱们肯定是在手机的浏览器中打开此链接,也是这个样子的

2.配置:

<activity android:name=".TestActivity4" android:exported="true"> <intent-filter><action android:name="android.intent.action.VIEW"/><category android:name="android.intent.category.DEFAULT" /><category android:name="android.intent.category.BROWSABLE" /><data android:scheme="app" android:host="test.my.app" android:pathPrefix="/path" /></intent-filter>
</activity>

配置完毕之后,点击手机浏览器加载的此网页的“”点我吧...“”既可以唤醒了。

对应的此页面获取参数:

 String TAG="TAG";Uri uri = getIntent().getData();if (uri != null) {// 完整的url信息String url = uri.toString();Log.e(TAG, "url: " + url);// scheme部分String scheme = uri.getScheme();Log.e(TAG, "scheme: " + scheme);// host部分String host = uri.getHost();Log.e(TAG, "host: " + host);//port部分
//            int port = uri.getPort();
//            Log.e(TAG, "host: " + port);// 访问路劲String path = uri.getPath();Log.e(TAG, "path: " + path);List<String> pathSegments = uri.getPathSegments();// Query部分String query = uri.getQuery();Log.e(TAG, "query: " + query);//获取指定参数值String goodsId = uri.getQueryParameter("query1");Log.e(TAG, "query1: " + goodsId)

注意:1.scheme,host,path都小写

            2.scheme不要用http或者https

关于APP唤醒的方法总结相关推荐

  1. iOS App 唤醒另一个App

    iOS App 唤醒另一个App 网上也有讲这块的,感觉讲得都不是很好.而且有一些细节根本没有讲清楚.这里重写整理一下相关知识点. 主要内容 URL Scheme 是什么? 项目中关键的配置 注意事项 ...

  2. Atitit.提升软件Web应用程序 app性能的方法原理 h5 js java c# php python android .net

    Atitit.提升软件Web应用程序 app性能的方法原理 h5 js java c# php python android .net 1. 提升单例有能力的1 2. 减少工作数量2 2.1. 减少距 ...

  3. android获取版本号报错,Android开发:获取安卓App版本号的方法步骤

    在Android开发过程中,想要开发一个完整功能的App,各个地方的内容都要涉及到,比如获取App的系统版本号就是必须要有的功能.Android的App版本号相关内容比iOS的App版本号内容要多,而 ...

  4. 5s的app显示无法连接服务器,苹果iphone5s手机无法连接App Store问题解决方法汇总...

    iphone5s无法连接App Store怎么办?大家在使用iphone5s过程中可能会遇到无法连接app store的问题,那怎么办呢?本文小编就主要给大家讲解一下如何解决iphone5s无法连接A ...

  5. vue js 和原生app调用回调方法问题

    vue js 和原生app调用回调方法问题 import Vue from 'vue' export default { name: 'list', components: { }, data: () ...

  6. 【uni-app】使用定义在App.vue的方法

    [uni-app]使用定义在App.vue的方法 前言 在methods中添加(推荐) 在globalData中添加方法(不建议) 前言 接手了一个小程序项目,考虑到后期可能会扩展到APP上,筛选技术 ...

  7. 安卓设置keychain_Android 7.0 SEAndroid app权限配置方法

    1.SEAndroid app分类 SELinux(或SEAndroid)将app划分为主要三种类型(根据user不同,也有其他的domain类型): 1)untrusted_app 第三方app,没 ...

  8. android 加网络权限管理,Android添加用户组及自定义App权限的方法

    Android:4.4.4 一.应用场景 在Android设备上,现在我们外接了一个USB转串口的设备,设备节点是/dev/ttyUSB0: # ls -l /dev/ttyUSB0 crw-rw-- ...

  9. LR11录制手机/pad App脚本多种方法介绍(Mobile App补丁包)

    总体来说,通过LR录制手机脚本的方式有三种: 1)通过代理方式录制,保证手机电脑在同一个网段: 2)通过抓包录制,在手机上安装Mobile Recorder: 3)通过安卓模拟器录制,本地安装andr ...

最新文章

  1. php No 'Access-Control-Allow-Origin' header is present on the requested resource.'Ajax跨域访问解决方法
  2. 【错误记录】Android Studio 4.2.1 编译报错 ( Kotlin 版本推荐设置 1.5.0 )
  3. Eureka 服务注册与发现02——集群版
  4. BIT的浅谈,简单理解
  5. 发送临时文件被服务器拒绝,临时会话说服务器拒绝了您发送离线文件的请求 - 卡饭网...
  6. JavaWeb课程复习资料——用于突击考试总结
  7. elasticsearch常用命令
  8. Python 基本数据类型 (二) - 字符串
  9. android奔溃日志手机查看
  10. [AU3]Backup Switch Config - cisco,huawei,h3c ---by onepc 153785587
  11. JavaScript学习笔记(三)——从简单模仿到创作
  12. Luogu P2068 统计和
  13. 巧用 10分钟邮箱 申请小红伞 免费KEY 92天
  14. 带宽、特征频率、截止频率、-3dB什么意思
  15. 精通使用K米短信教程
  16. 蚂蚁金服AntV开源地理可视化引擎 L7 2.0——聊聊AntV背后那些事
  17. android 自动运行 app,「定时启动」时间一到自动运行指定的 App(Android)
  18. KMPlayer播放mkv视频不出声音的解决办法
  19. R中的特殊值NAN\NA\inf\NULL
  20. 互联网赚钱项目有哪些?目前最火的互联网项目

热门文章

  1. PDF 破解软件注册码
  2. tess4j linux so文件,linux上安装tess4j项目
  3. C++扑克牌记忆匹配游戏
  4. 网关 Spring Cloud Gateway 实战负载均衡(Spring Cloud Loadbalancer)
  5. BVT BAT SVT
  6. yy 服务器维护中 图片无法显示,解决简书图片不显示问题“系统维护中,图片暂时无法加载”...
  7. 那些让 Web 开发者们深感意外的事情
  8. 在anaconda中安装pytorch的经常出现的错误
  9. ENSP模拟器防火墙增加内存
  10. 微信小程序点播插件_小程序直播插件接入 - 微信小程序