1. 项目中去启动第三方的APP的 时候碰到了这个问题 ,具体log如下,是因为有些手机有关联启动的限制,不打开这个的话,是不能启动第三方应用的
0-17 17:51:16.784 10944-11056/ai.aitek.va W/System.err: java.lang.SecurityException: Not allowed to start activity Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 pkg=com.mobike.mobikeapp cmp=com.mobike.mobikeapp/.SplashActivity }
10-17 17:51:16.784 10944-11056/ai.aitek.va W/System.err: at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1834)
10-17 17:51:16.784 10944-11056/ai.aitek.va W/System.err: at android.app.Instrumentation.execStartActivity(Instrumentation.java:1531)
10-17 17:51:16.784 10944-11056/ai.aitek.va W/System.err: at android.app.ContextImpl.startActivity(ContextImpl.java:791)
10-17 17:51:16.784 10944-11056/ai.aitek.va W/System.err: at android.app.ContextImpl.startActivity(ContextImpl.java:768)
10-17 17:51:16.784 10944-11056/ai.aitek.va W/System.err: at android.content.ContextWrapper.startActivity(ContextWrapper.java:356)
10-17 17:51:16.784 10944-11056/ai.aitek.va W/System.err: at ai.aitek.applauncher.a$a.a(AppWrapper.java:163)
10-17 17:51:16.784 10944-11056/ai.aitek.va W/System.err: at ai.aitek.applauncher.a.a(AppWrapper.java:86)
10-17 17:51:16.784 10944-11056/ai.aitek.va W/System.err: at ai.aitek.applauncher.AppLauncher$1.onQuery(AppLauncher.java:95)
10-17 17:51:16.784 10944-11056/ai.aitek.va W/System.err: at com.aispeech.dui.dds.agent.Agent.onMessage(Agent.java:220)
10-17 17:51:16.785 10944-11056/ai.aitek.va W/System.err: at com.aispeech.dui.BusClient.spin(BusClient.java:452)
10-17 17:51:16.785 10944-11056/ai.aitek.va W/System.err: at com.aispeech.dui.BaseNode.run(BaseNode.java:167)
10-17 17:51:16.785 10944-11056/ai.aitek.va W/System.err: at java.lang.Thread.run(Thread.java:761)
2. vivo的关联启动页面如下所示
device-2018-10-17-181446.png
3. 解决方案如下
/**
* Created by zss on 18-10-17.
*/
public class ModelAdaptationUtils {
private ModelAdaptationUtils() {
}
/**
* 跳转关联启动页面
*/
public static void associationStart() {
try {
Intent startIntent = new Intent();
startIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
ComponentName componentName = null;
String brand = Build.BRAND;
LogUtils.e("launchIt zss brand===", brand);
if (brand.contains("nubia")) {
//适配努比亚打不开QQ音乐的问题,需要开启自启动权限
componentName = new ComponentName("cn.nubia.security2",
"cn.nubia.security.appmanage.selfstart.ui.SelfStartActivity");
} else if (brand.contains("vivo")) {
//适配vivo Xplay6半屏打不开QQ音乐的问题,需要开启关联启动权限
componentName = new ComponentName("com.vivo.appfilter",
"com.vivo.appfilter.activity.StartupManagerActivityRom30");
}
startIntent.setComponent(componentName);
CoreApp.getContext().startActivity(startIntent);
} catch (Exception e1) {
e1.printStackTrace();
}
}
}
网友评论