在webview中启用桌面版网站(android app)

时间:2015-05-06 14:56:00

标签: android webview

我希望在我的应用程序上显示类似桌面版网站的Facebook我尝试使用" facebook.getSettings()。setUserAgentString(" Android");"但它对我没有用。 请帮助!!

public class FaceBookFragment extends Fragment {
    WebView facebook;

    public FaceBookFragment() {

    }

    @SuppressLint({ "SetJavaScriptEnabled", "JavascriptInterface" })
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.webview, container, false);
        WebView facebook = (WebView) rootView.findViewById(R.id.webview);
        facebook.setWebViewClient(new MyWebViewClient());
        WebSettings webSettings = facebook.getSettings();
        webSettings.setJavaScriptEnabled(true);
        facebook.loadUrl("https://www.facebook.com/login/");
        return rootView;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }
}

0 个答案:

没有答案