facebook not showing message by sending via Intent - java

public void shareMessage(){
final Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, text);
getContext().startActivity(Intent.createChooser(intent, "Share"));
}
When I use "text/plain", Facebook comes up as an option but the text does not load up when selecting it. But the text does load for Twitter,email, SMS.
Has anyone else encountered this problem?

As mentioned in the comments , Facebook has disabled the share intent a few years back Android and Facebook share intent , it doesn't handle EXTRA_SUBJECT or EXTRA_TEXT fields,
Use the Facebook api , Instructions found here --> https://developers.facebook.com/docs/android/share#share_options

Related

How can I prevent my app from showing specific apps on startActivity()

When a user clicks a button in my app, it's supposed to launch an SMS app. To to this, I simply fired an intent.
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.fromParts("sms", "+234000000000", null));
intent.putExtra("sms_body", "Hello!"));
if (intent.resolveActivity(getActivity().getPackageManager()) != null) startActivity(intent);
This works perfectly fine! The only problem is that Facebook Messenger is among the list of apps that show up and I don't want that.
How can I filter this list and remove specific apps like Messenger?
Yes, you can restrict your app to open just android default messaging app.
Uri uri = Uri.parse("sms:+444498494984");
Intent intent = new Intent(Intent.ACTION_SENDTO, uri);
//android sms app package name
intent.setPackage("com.google.android.apps.messaging");
intent.putExtra("sms_body", "message to send");
if (intent.resolveActivity(getPackageManager()) != null)
{
startActivity(intent);
}
It is trying to give the user a choice on their favourite SMS app, Don't forget that Facebook Messenger can also manage SMS now that is why it is showing up as a choice. In my experience, Unless the user selects 'always' it can't be avoided. Imagine if the user has other apps to manage SMS we can't force them to use our preferred messaging app.

How to solve android email intent problem?

I am having a problem with android email intent.....i need to open email app so that the user can provide feedback for my app.It doesn't open when i use this..throws an ActivityNotFoundException .....i am using my phone ,not an emulator and my phone has email and gmail apps in it.
Help me solve??
Here is my code:
Intent intent= new Intent(Intent.ACTION_SENDTO);
intent.setData(Uri.parse("mailto:"));
intent.setType("text/plain");
String[] mail={"someone#gmail.com"};
intent.putExtra(Intent.EXTRA_SUBJECT,"");
intent.putExtra(Intent.EXTRA_TEXT,"");
intent.putExtra(Intent.EXTRA_EMAIL,mail);
startActivity(intent);
Any and all comments are appreciated :)
For your case, what ActivityNotFoundException most likely means that in your phone you don't have any default email app email application installed on your device like Gmail, so when you launch the Intent you receive this error.
You can try to handle that exception like this:
try {
startActivity(Intent.createChooser(i, "Send mail"));
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(Activity.this, "no email app",Toast.LENGTH_SHORT).show();
}
From the android docs, An intent allows you to start an activity in another app by describing a simple action you'd like to perform (such as "view a map" or "take a picture") in an Intent object. This type of intent is called an implicit intent because it does not specify the app component to start, but instead specifies an action and provides some data with which to perform the action.
When you call startActivity() or startActivityForResult() and pass it an implicit intent, the system resolves the intent to an app that can handle the intent and starts its corresponding Activity. If there's more than one app that can handle the intent, the system presents the user with a dialog to pick which app to use.`
So, in your case, the system couldn't find an app to resolve the intent to as #Tamir mentioned.
For more information , look into this Stack Overflow post: Send Email Intent
it works for me :
String[] recipients;
Intent intent = new Intent(Intent.ACTION_SEND);
recipients = new String[]{"someone#gmail.com"};
intent.putExtra(Intent.EXTRA_EMAIL, recipients);
intent.setType("text/html");
intent.setPackage("com.google.android.gm");
try {
activity.startActivity(Intent.createChooser(intent, "Send"));
}
catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(Activity.this, "no email app",Toast.LENGTH_SHORT).show();
}

Android sharing intent won't work with reddit

My sharing intent code does work with all other apps but not reddit when i try to share it with reddit i get a toast saying "Something went wrong." I tried several codes but none worked for me. Here's my current code, Please help me solving this problem.
private void share(File file){
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("image/*");
intent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///"+file.getAbsolutePath()));
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(Intent.createChooser(intent,"Share with..."));
}

What to add in the body of a share Intent before launching an android app?

I know how to add a share button in android, but when I click on it I want the intent to store the link of the same app in playstore. However, I don't understand how to do this because I am trying to find the link of an app that hasn't been published yet.
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
String shareBody = "Here is the share content body";
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Subject Here");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Add the app link here so that it is shown in playstore");
startActivity(Intent.createChooser(sharingIntent, "Share via"));
I know it can be achieved via Firebase Remote configurations, but is there any other way to do so.
you can do this by following:
startActivity(new Intent(Intent.ACTION_VIEW,
Uri.parse("http://play.google.com/store/apps/details?id=" + this.getPackageName())));
this is your link after publishing app: "http://play.google.com/store/apps/details?id=" + this.getPackageName()

Android Share Link with WhatsApp

I am trying to share link with my android app with this:
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, share);
intent.putExtra(android.content.Intent.EXTRA_SUBJECT, "");
mContext.startActivity(intent);
this is the share Strong :
Check out my link:\n http://my123domain.com/v.php?vid=123456-123456-123456
But when i share it with Whats App the link is not click able,
Any idea Why?
Whatsapp does not allow sending clickable text links to people who do not have you in their contact list. Make sure receiving party have you in their contact list.

Categories

Resources