Android studio Facebook喜欢和评论在Android webview上不起作用
我用Android studio和FB share尝试过webview,其他社交媒体共享按钮都很好用。但我的网站上的FB direct like和comment按钮不起作用。当我按下like按钮时,我可以看到白色屏幕,左上方屏幕编号为1。请帮助我 MainActivity.Java Activity_main.xmlAndroid studio Facebook喜欢和评论在Android webview上不起作用,android-studio,android-webview,Android Studio,Android Webview,我用Android studio和FB share尝试过webview,其他社交媒体共享按钮都很好用。但我的网站上的FB direct like和comment按钮不起作用。当我按下like按钮时,我可以看到白色屏幕,左上方屏幕编号为1。请帮助我 MainActivity.Java Activity_main.xml 这是由于Facebook用户auth造成的,不幸的是android webview与auth系统不完全兼容,我在webview应用程序中使用的另一种方法是对我使用的评论系统的访问进
这是由于Facebook用户auth造成的,不幸的是android webview与auth系统不完全兼容,我在webview应用程序中使用的另一种方法是对我使用的评论系统的访问进行身份验证 在我的应用程序中,当用户单击评论时,我的应用程序内会打开一个Google Chrome选项卡,显示评论页面。当用户未登录时,Chrome会对用户进行身份验证,而无需关闭或最小化我的应用程序即可打开Google Chrome。一切都是在我自己的应用程序中完成的 要在我向shouldOverrideUrlLoading添加意图时启动Chrome选项卡,下面是我的代码示例 @凌驾 公共布尔值应覆盖EurlLoadingWebView视图,字符串url{ 如果url.containscomments{ Uri=Uri.parseurl; customtabsinent.Builder=新建customtabsinent.Builder; builder.build.launchUrlPostActivity.this,uri; 返回true; } 否则{ view.loadUrlurl; 返回true; }
}你能发布一些你试过的代码吗?单从你的问题很难说问题是什么。我现在已经编辑了我的问题正文。这是我的密码。请帮帮我。此代码用于共享所有社交媒体。但不像按钮和注释FB那样工作。也可以打印你的答案。请告诉我这个代码应该放在哪里?请一步一步地解释。我看到你在你的网站上使用wordpress,为了让我的建议发挥作用,你必须在你的URL中有符合模式的东西,在设置>永久链接中选择自定义结构和类型:/app post/%postname%/现在在Android studio的项目中打开build.gradle应用程序,并在依赖项中添加以下行:实现“androidx.browser:browser:1.3.0-alpha01”应在WordPress上进行设置?并完成,将MainActivity中WebViewClient中的shouldOverrideUrlLoading替换为我在上面的答案中发布的shouldOverrideUrlLoading,并将此行更改为:if url.containscomments{by if url.contains/app post/{
package com.example.neermaicom;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.WindowManager;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import static android.content.Intent.*;
public class MainActivity extends AppCompatActivity {
private WebView webView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
getSupportActionBar().hide();
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
webView = findViewById(R.id.webview);
webView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url == null || url.startsWith("http://") || url.startsWith("https://")) return false;
try {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
view.getContext().startActivity(intent);
return true;
} catch (Exception e) {
return true;
}
}
});
webView.loadUrl("http://www.neermai.com");
WebSettings webSettings = webView.getSettings();
webSettings.setJavaScriptEnabled(true);
}
//This method require to use back button if want to go previous web page
@Override
public void onBackPressed() {
if(webView.canGoBack()){
webView.goBack();
}else {
super.onBackPressed();
}
}
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<WebView
android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>