I have a facebook page and want to open it through the Facebook App and not through the browser. How to do so ?
For example the amazon page which is: https://www.facebook.com/Amazon
I tried this:
String uri = "facebook://facebook.com/amazon";
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
startActivity(intent);
This opens the Facebook App but now the facebook page.
Thanks!
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("fb://profile/"+FB_ID));
//or Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("fb://page/"+FB_ID));
startActivity(intent);
where FB_ID - ID of group
Okay I solved it. Had to use this:
"fb://page/9465008123"
Related
I am trying to access photo libraray in android device using this code:
txtSelectPhoto.setOnClickListener(v->{
Intent i = new Intent(Intent.ACTION_PICK);
i.setType("image/*");
startActivityForResult(i,GALLERY_CHANGE_PROFILE);
});
but when it opens it just gives me a blank screen of the device folders with no photos like this although there are photos on the device.. is there any way to solve this?
Remove setType() and instead pass a Uri in the Intent constructor, representing the collection that you want the user to pick from:
txtSelectPhoto.setOnClickListener(v->{
Intent i = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(i, GALLERY_CHANGE_PROFILE);
});
Or, keep the MIME type and switch to ACTION_GET_CONTENT:
txtSelectPhoto.setOnClickListener(v->{
Intent i = new Intent(Intent.ACTION_GET_CONTENT);
i.setType("image/*");
startActivityForResult(i, GALLERY_CHANGE_PROFILE);
});
I'm coding an android - java app which can open a Facebook post url
(ex: https://www.facebook.com/BaHangXom.0/videos/2377836809193490).
I tried some ways to start Facebook app with intent but unsuccessfully.
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("fb://facewebmodal/f?href=" + "https://www.facebook.com/BaHangXom.0/videos/2377836809193490"));
intent.setPackage("com.facebook.katana");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
Could you please give me any idea?
Thank you so much.
Simply open the url:
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/BaHangXom.0/videos/2377836809193490"));
startActivity(intent);
This is the most simple and universal way: user will be able to choose (and remember the choice) whether they want to open the link via main Facebook app, Facebook lite, or the browser.
You can open the facebook app using this code:
public static Intent newFacebookIntent(PackageManager pm, String url) {
Uri uri = Uri.parse(url);
try {
ApplicationInfo applicationInfo = pm.getApplicationInfo("com.facebook.katana", 0);
if (applicationInfo.enabled) {
// http://stackoverflow.com/a/24547437/1048340
uri = Uri.parse("fb://facewebmodal/f?href=" + url);
}
} catch (PackageManager.NameNotFoundException ignored) {
}
return new Intent(Intent.ACTION_VIEW, uri);
}
I can open TikTok to a user's profile with the below code, but how do I open TikTok to its Homepage?
Uri uri = Uri.parse("https://vm.tiktok.com/"+"tiktokExtension");
Intent tiktokIntent = new Intent(Intent.ACTION_VIEW, uri);
tiktokIntent.setPackage("com.zhiliaoapp.musically");
startActivity(tiktokIntent);
you start tiktok application this way :
try{
Intent intent = new Intent("com.zhiliaoapp.musically");
startActivity(intent);
}catch(ActivityNotFoundException e){
//if the app doesn't exist do some stuff , like redirection to playstore.....
}
I try to share picture from a fragment in android studio to facebook
..... the application has many of fragments so if i press on "share" the picture in this fragment will share on my Facebook and so on for the rest.
I used Intent to share text but this not work :
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, desc.getText().toString());
startActivity(Intent.createChooser(intent, "Share with"));
share(desc.getText().toString());
Thanks
try this reference:
: http://simpledeveloper.com/how-to-share-an-image-on-facebook-in-android/
hope it will help you.if it is working accept my answer
You can try this with the use of facebook sdk.
private void shareFacebook(){
if (!ShareDialog.canShow(ShareLinkContent.class)) return;
ShareDialog dialog = new ShareDialog(this);
ShareLinkContent.Builder builder = new ShareLinkContent.Builder();
builder.setContentUrl(Uri.parse("FileSharingUrl"));
builder.setImageUrl(Uri.parse("image url"));
if (mSharePhotoosUrl) {
builder.setContentDescription("body description");
}
if (mShareCreator) {
builder.setContentTitle("title if any");
}
dialog.show(getActivity(), builder.build());
}
}
The problem I have is that when this intent is started there are no apps to show. Why is that? I need all apps to be visible since onClick the button will go to any app the user wants to and save it (use this app as default). What could be the solution?
Intent intent = new Intent(Intent.ACTION_ALL_APPS);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
String title = getResources().getString(R.string.chooser_title);
Intent chooser = Intent.createChooser(intent, title);
chooser.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(chooser);
Try-
Intent pickIntent = new Intent(Intent.ACTION_ALL_APPS);
pickIntent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
pickIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(pickIntent);
This will give you all the apps in a list-
Intent pickIntent = new Intent(Intent.ACTION_MAIN, null);
pickIntent.addCategory(Intent.CATEGORY_LAUNCHER);
List pkgAppsList = getPackageManager().queryIntentActivities( pickIntent, 0);
Log.d(MainActivity.class.getSimpleName(), pkgAppsList.toString());
//startActivity(pickIntent);
pkgAppsList will have the list of all the applications. Hope this solves your problem.