0

I have a button link to facebook account but it connect to Google browser in my mobile (as shown) but I don't want that, I want it to take me to facebook application in my mobile and if it doesn't exist, it takes me to Google play application to download/install facebook, does anybody know how?

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);

            }     
        });         
    }
}
Kai
  • 38,985
  • 14
  • 88
  • 103
DaraS
  • 3
  • 3

2 Answers2

1

use android facebook sdk create an app at http://developers.facebook.com/ and proceed

NavinRaj Pandey
  • 1,674
  • 2
  • 26
  • 40
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); 
  }

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

Community
  • 1
  • 1
P-RAD
  • 1,293
  • 2
  • 15
  • 36