按钮链接到Facebook应用程序

时间:2014-08-19 08:01:32

标签: java android xml facebook

我有一个指向facebook帐户的按钮链接,但它在我的手机中连接到谷歌浏览器(如图所示),但我不想要,我希望它带我到我的手机中的Facebook应用程序,如果它没有& #39; t存在,它需要我去谷歌播放应用程序来下载/安装facebook,有人知道怎么做?

package com.el.dom;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.widget.Button;
import android.view.View;
import android.view.View.OnClickListener;

public class PageAb extends Activity {

    Button dclink;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.ab);
        addListenerOnButton();    
    }

    public void addListenerOnButton() {

        dclink= (Button) findViewById(R.id.dctec);          

        dclink.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View arg0) {

              Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/blah"));
                startActivity(browserIntent);

            }     
        });         
    }
}

2 个答案:

答案 0 :(得分:1)

使用android facebook sdk在http://developers.facebook.com/创建应用并继续

答案 1 :(得分:0)

    try {
  //try to open page in facebook native app.
  String uri = "fb://page/" + yourFBpageId;    //Cutsom URL
  Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
  startActivity(intent);   
  }
  catch (ActivityNotFoundException ex){
  //facebook native app isn't available, use browser.
  String uri = "http://touch.facebook.com/pages/x/" + yourFBpageId;  //Normal URL  
  Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(uriMobile));    
  startActivity(i); 
  }

How to navigate user to a facebook page via Android's facebook api?

复制