I'm trying to open a facebook profile with a button, but I've tried and it always opens with the browser and not with the facebook app, can someone help me please, that's how I'm doing at the moment.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.facebook);
//FACEBOOK
Uri uri = Uri.parse("https://www.facebook.com/uniagustiniana?ref=hl/");
Intent intent = new Intent(Intent.ACTION_VIEW,uri);
try{
startActivity(intent);
}catch(Exception e){
e.printStackTrace();
}finally {
finish();
}
}
This requires the "Facebook page id" , which is obtained in this way:
To open the application is done in this way:
I recommend you validate the case in which there is no installed application. In this case it will open the web page if it does not find the application installed:
This might work:
The method returns the correct facebook URL whether you have the app installed or not.
Then the Intent is launched
Hope this can help you