2012-01-26 5 views
0

私のアプリはFacebookアカウントを表示する必要があります。だから私は、Facebookのアプリケーションを開くか、それが利用できない場合は、Webブラウザを希望します。現在、私はこの方法でTwitterアプリを開くことができ、システムは何をすべきかを尋ねる(Twitterアプリまたはブラウザ)。ここで コードです:別のFacebookアプリを開いていますか? "Twitterの方法"で

WebView myWebView = (WebView) findViewById(R.id.webViewProfile); // 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("https://mobile.twitter.com/"+name); // Specify the URL to load when the application starts 
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 
myWebView.getSettings().setUserAgentString("BumpMe"); 

この方法は非常に良いですし、私はFacebookのための同じ結果を持っていると思います。私はTwitterのためのようにそれを行うことができますどのように

String uri = "facebook://facebook.com/info?user="+fbid; 
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri)); 
context.startActivity(intent); 

しかし、アプリケーションがインストールされていない場合、それは動作しません...

:現在、私はそのようなFacebookアプリを開くことができますか?これは、Twitterと連携

おかげ

答えて

2

理由は、Twitterアプリがhttps://mobile.twitter.com/ * URLの意向フィルタ内を扱うということです。そのURLを持つインテントを発行すると、Twitterアプリケーションが呼び出されます。 Facebook(または他のアプリ)でこれを行う唯一の方法は、インテントフィルタで宣言されたパターンの1つと一致するURLを使用することです。たぶんhttp://m.facebook.com/ ...?

+0

[OK]をクリックして、アプリケーションが特定のリンクパターンを処理するかどうかを知る方法はありますか?どこかリストがありますか? – Gp2mv3

0

ユーザーにアプリまたはブラウザの選択肢を提供する代わりに、別の方法として、アプリを開こうとすると、Webページを開くことができない場合があります。ここで私はTwitterのためにこうしています:

long userID = tweet.getUser().getId(); 
try { 
    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("twitter://user?user_id=" + userID)); 
    startActivity(intent); 
}catch (Exception e) { 
    startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://twitter.com/intent/user?user_id=" + userID))); 
} 
関連する問題