Android 11及以下版本Google Meet通过Intent打开链接崩溃求助
Google Meet在Android 11/10及以下版本Intent打开链接崩溃问题及临时解决方案
问题描述
在Android 11、10及更低版本中,Google Meet应用的com.google.android.libraries.communications.conference.ui.intents.AssistantNewUrlHandlerActivity存在权限处理缺陷:该Activity声明了android.permission.CALL_PHONE权限,但未正确配置对外调用的权限规则。当第三方应用通过Intent.ACTION_VIEW打开Meet会议链接时,系统会解析到这个有问题的Activity,触发SecurityException(权限拒绝)导致崩溃。
复现代码
private fun openGoogleMeetUrl() { val url = "https://meet.google.com/new" val webpage: Uri = Uri.parse(url) val intent = Intent(Intent.ACTION_VIEW, webpage) val resolveActivity = intent.resolveActivity(packageManager) if (resolveActivity != null) { startActivity(intent) } else { Log.w("DEBUG_TAG", "Unable to find activity to launch.") } }
崩溃日志
8199-8199/? E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.chromecustomtab, PID: 8199 java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.VIEW dat=https://meet.google.com/... cmp=com.google.android.apps.meetings/com.google.android.libraries.communications.conference.ui.intents.AssistantNewUrlHandlerActivity } from ProcessRecord{ea9c15f 8199:com.example.chromecustomtab/u0a152} (pid=8199, uid=10152) requires android.permission.CALL_PHONE at android.os.Parcel.createException(Parcel.java:2071) at android.os.Parcel.readException(Parcel.java:2039) at android.os.Parcel.readException(Parcel.java:1987) at android.app.IActivityTaskManager$Stub$Proxy.startActivity(IActivityTaskManager.java:3851) at android.app.Instrumentation.execStartActivity(Instrumentation.java:1705) at android.app.Activity.startActivityForResult(Activity.java:5192) at androidx.activity.ComponentActivity.startActivityForResult(ComponentActivity.java:574) at android.app.Activity.startActivityForResult(Activity.java:5150) at androidx.activity.ComponentActivity.startActivityForResult(ComponentActivity.java:560) at android.app.Activity.startActivity(Activity.java:5521) at android.app.Activity.startActivity(Activity.java:5489) at com.example.chromecustomtab.MainActivity.openWithUrlIntent(MainActivity.kt:40) at com.example.chromecustomtab.MainActivity.onCreate$lambda-0(MainActivity.kt:22) at com.example.chromecustomtab.MainActivity.$r8$lambda$z3Mks0G0-clLlQbj_fjGy_IFcVM(Unknown Source:0) at com.example.chromecustomtab.MainActivity$$ExternalSyntheticLambda0.onClick(Unknown Source:2) at android.view.View.performClick(View.java:7125) at com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:1119) at android.view.View.performClickInternal(View.java:7102) at android.view.View.access$3500(View.java:801) at android.view.View$PerformClick.run(View.java:27336) at android.os.Handler.handleCallback(Handler.java:883) at android.os.Handler.dispatchMessage(Handler.java:100) at android.os.Looper.loop(Looper.java:214) at android.app.ActivityThread.main(ActivityThread.java:7356) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930) Caused by: android.os.RemoteException: Remote stack trace: at com.android.server.wm.ActivityStackSupervisor.checkStartAnyActivityPermission(ActivityStackSupervisor.java:1043) at com.android.server.wm.ActivityStarter.startActivity(ActivityStarter.java:760) at com.android.server.wm.ActivityStarter.startActivity(ActivityStarter.java:583) at com.android.server.wm.ActivityStarter.startActivityMayWait(ActivityStarter.java:1288) at com.android.server.wm.ActivityStarter.execute(ActivityStarter.java:514)
临时解决方案
以下几种方案可绕过该问题,避免崩溃:
方案1:指定Google Meet包名打开
直接限定Intent仅在Google Meet应用内处理,避免系统解析到有问题的Activity:
private fun openGoogleMeetUrl() { val url = "https://meet.google.com/new" val webpage: Uri = Uri.parse(url) val intent = Intent(Intent.ACTION_VIEW, webpage) // 指定Meet包名,引导系统选择正确的处理Activity intent.setPackage("com.google.android.apps.meetings") try { startActivity(intent) } catch (e: SecurityException) { // 权限异常时 fallback 到浏览器打开 intent.setPackage(null) startActivity(intent) } catch (e: ActivityNotFoundException) { Log.w("DEBUG_TAG", "Google Meet未安装,使用浏览器打开") intent.setPackage(null) startActivity(intent) } }
方案2:捕获异常并降级处理
在启动Activity时捕获权限拒绝异常,出现崩溃时自动切换到浏览器打开链接:
private fun openGoogleMeetUrl() { val url = "https://meet.google.com/new" val webpage: Uri = Uri.parse(url) val intent = Intent(Intent.ACTION_VIEW, webpage) val resolveActivity = intent.resolveActivity(packageManager) if (resolveActivity != null) { try { startActivity(intent) } catch (e: SecurityException) { Log.w("DEBUG_TAG", "打开Meet失败,切换至浏览器") // 清除组件信息,让系统选择浏览器应用 intent.component = null startActivity(intent) } } else { Log.w("DEBUG_TAG", "无法找到可打开链接的应用") } }
方案3:提前检测并替换问题Activity
检查系统解析到的Activity是否为有问题的AssistantNewUrlHandlerActivity,若是则手动替换为Meet的主Activity:
private fun openGoogleMeetUrl() { val url = "https://meet.google.com/new" val webpage: Uri = Uri.parse(url) val intent = Intent(Intent.ACTION_VIEW, webpage) val resolveInfo = packageManager.resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY) if (resolveInfo != null) { val problematicActivity = "com.google.android.libraries.communications.conference.ui.intents.AssistantNewUrlHandlerActivity" if (resolveInfo.activityInfo.name == problematicActivity) { // 替换为Meet主Activity intent.component = ComponentName("com.google.android.apps.meetings", "com.google.android.apps.meetings.MainActivity") } try { startActivity(intent) } catch (e: Exception) { Log.w("DEBUG_TAG", "打开失败,使用浏览器", e) intent.component = null startActivity(intent) } } else { Log.w("DEBUG_TAG", "无法找到可打开链接的应用") } }
说明
该问题根源是Google Meet应用的权限配置错误,需Google官方修复上述Activity的权限声明逻辑。上述方案均为临时绕过手段,待Google修复后可移除相关处理。
内容的提问来源于stack exchange,提问作者Hossain Khan
相关产品推荐
相关产品推荐

