除了信使之外,一切都按其应有的方式运行。
代码
if (url.startsWith("www.messenger.com")) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(intent);
return true;
}
对于信使,即使对于这个一般意图代码,它也不会显示使用信使打开的选项
if (url.startsWith("intent")){
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_VIEW);
if (sendIntent.resolveActivity(getPackageManager()) != null) {
startActivity(sendIntent);
}
return true;
}
使用协议错误日志:
2020-08-28 17:21:24.098 16802-16802/com.mesports.ga E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.mesports.ga, PID: 16802
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=intent://user/102700191461284/?intent_trigger=mme&ref=c4254e87a85bef8dd4c3e74bc771d099dda9c6bb22e340c644&nav=discover&source=customer_chat_plugin&source_id=1507329&metadata={"referer_uri":"https:\/\/m-esports.ga\/f2d7b535e73be5c"} }
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:2014)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1675)
at android.app.Activity.startActivityForResult(Activity.java:4586)
at androidx.fragment.app.FragmentActivity.startActivityForResult(FragmentActivity.java:676)
at android.app.Activity.startActivityForResult(Activity.java:4544)
at androidx.fragment.app.FragmentActivity.startActivityForResult(FragmentActivity.java:663)
at android.app.Activity.startActivity(Activity.java:4905)
at android.app.Activity.startActivity(Activity.java:4873)
at com.mesports.ga.MainActivity$MyWebviewClient.shouldOverrideUrlLoading(MainActivity.java:194)
at android.webkit.WebViewClient.shouldOverrideUrlLoading(WebViewClient.java:77)
at org.chromium.android_webview.AwContentsClientBridge.shouldOverrideUrlLoading(chromium-Monochrome.aab-stable-418308173:16)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:326)
at android.os.Looper.loop(Looper.java:160)
at android.app.ActivityThread.main(ActivityThread.java:6762)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
即使使用 http 和 https 协议,它也会显示相同的错误
这是 Android 清单文件
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mesports.ga">
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
我终于弄清楚如何用WebView做到这一点。
首先,从页面设置 -> 消息传递获取您的 Messenger URL。如下图所示。
之后处理由外部浏览器打开的“意图:”情况。使用“https://”与您的 Messenger URL。
if(url.startsWith("intent:"))
{
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("https://m.me/***********"));
startActivity(i);
return true;
}
而且,你已经完成了。唷!
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)