Android调用第三方app(Scheme隐式以及显示调用)
一、隐式调用
1.第三方app:manifest中配置能接受Scheme方式启动的
<activity android:name=".MainActivity">
<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:host="test"
android:scheme="app"/>
intent-filter>
activity>
2. 自己app调用
Uri uri=Uri.parse("app://test"); // app://test" 相当于 http://www.baidu.com
Intent intent=new Intent(Intent.ACTION_VIEW,uri);
startActivity(intent);
二、显示调用
1.第三方app:manifest中设置exported = ‘true’
<activity android:name=".WelcomeActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
intent-filter>
activity>
3. 自己app调用
Intent intent = new Intent();
intent.setAction(Intent.ACTION_MAIN);
//前提:知道要跳转应用的包名、类名
String packageName = "com.wpl.csdemo";
String className = "com.wpl.csdemo.WelcomeActivity";
ComponentName componentName = new ComponentName(packageName, className);
intent.setComponent(componentName);
startActivity(intent);
注意:这两种方式的设置只是针对某个页面,都只是在自己应用中跳转第三方应用,并不是真正的唤醒,比如应用A已经在后台存在了,应用B调用以上两种方式后,只是在应用B中重新打开了一个应用A,此时的应用A是相当与存在两个,一个是在后台单独存在,一个是依存应用B存在,是添加到应用B的栈中的。
真正意义的唤醒app,实现ios scheme相同效果:https://blog.csdn.net/Silence_Sep/article/details/80527472
更多相关文章
- android 异常情况下的onSaveInatanceState()与onRestoreIntanceS
- 程序分析:Android漏洞挖掘技术
- Android拍照流程
- Android(安卓)开发之serviceManager分析
- Android(安卓)默认AP名字,以及AP名字存储路径
- Android(安卓)VOIP拨打电话机制分析
- schema唤起指定页面
- Android中调用Paint的measureText()方法取得字符串显示的宽度值
- Android之Activity的启动方式