用于在android中打开facebook app的URL

时间:2011-06-06 19:07:51

标签: android facebook url

  

可能重复:
  Open Facebook page from Android app?

我的Android应用程序中有一个webview,我想在其中打开一个链接,将facebook应用程序打开到我的粉丝页面。在iOS中,您可以说fb:// ...它将打开Facebook应用程序。有没有办法在Android中做到这一点?我已经覆盖了shouldOverrideUrlLoading,所以我可以拦截它并在需要时启动一个意图。

2 个答案:

答案 0 :(得分:6)

您需要使用Intents。以下是调用FB应用程序的方法(如果已安装):

Intent intent = new Intent();
intent.setClassName("com.facebook.katana","com.facebook.katana.ProxyAuth");
intent.putExtra("client_id", applicationId);
mAuthActivityCode = activityCode;
activity.startActivityForResult(intent, activityCode);

此代码取自Facebook API,后者授权操作。 Ajust以满足您的需求。代码为版权所有2010 Facebook,Inc。,根据Apache许可证2.0版获得许可。

答案 1 :(得分:0)

myWebView = (WebView) findViewById(R.id.webview); // Create an instance of WebView and set it to the layout component created with id webview in main.xml
        myWebView.getSettings().setJavaScriptEnabled(true);
        myWebView.loadUrl("http://m.facebook.com/pages/xxxxx-xxxxx-xxxxx/xxxxxxxxxx"); // Specify the URL to load when the application starts
        //myWebView.loadUrl("file://sdcard/"); // Specify a local file to load when the application starts. Will only load file types WebView supports
        myWebView.setWebViewClient(new WebViewKeep());
        myWebView.setInitialScale(1); // Set the initial zoom scale
        myWebView.getSettings().setBuiltInZoomControls(true); // Initialize zoom controls for your WebView component
        myWebView.getSettings().setUseWideViewPort(true); // Initializes double-tap zoom control

检查这是否适合您。