i made news applicaion in android using RSS feed and now i want to share some news ie i want to upload links from my app to facebook, twitter etc.Is it possible?
Thanks
Try this :
findViewById(R.id.btnEnvoyer).setOnClickListener(
new Button.OnClickListener() {
public void onClick(View v) {
Intent sendMailIntent = new Intent(Intent.ACTION_SEND);
sendMailIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.Share_Mail_Subject));
sendMailIntent.putExtra(Intent.EXTRA_TEXT, getString(R.string.Share_Mail_Text));
sendMailIntent.setType("text/plain");
startActivity(Intent.createChooser(sendMailIntent, "Email / SMS / Tweet ?"));
}
}
);
works just fine in my latest app if you want to test it :
Comis Strips in Brussels
=> Hit [Menu], then [Share], then the button [Send Email / SMS / Tweet]=R.id.btnEnvoyer in my layout file to see the alternatives the user can choose from ...
Hope this helps you a bit ...
H.
Yes it is. Twitter and Facebook has api for you to do those.
Take a look at these
Twitter Java APIs also checkout the facebook developer page
Related
I have a share button. I share a message with some text and URL. It working well with whatsapp, Twitter and Gmail. But, in facebook share I'm able to share website link only. After, searching on web I have found ShareDialog class for facebook share.My question is how detect (ex: onClick() for facebook icon) when user click facebook icon on android default share dialog. Is it correct way ? or any other alternates is there?
My code :
public void shareApp() {
Intent sendIntent = new Intent();
String websiteLink = "https://www.manam.com";
String playStoreLink = "http://www.google.com";
String msg = "\nHey, found this cool & easy on-demand app.";
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_SUBJECT, msg);
sendIntent.putExtra(Intent.EXTRA_TEXT,playStoreLink + msg);
sendIntent.setType("text/plain");
startActivity(Intent.createChooser(sendIntent, ""));
}
It's Facebook policy.
When you implement sharing, your app should not pre-fill any content to be shared. This is inconsistent with Facebook Platform Policy, see Facebook Platform Policy, 2.3.
I also don't see an option to detect click on facebook icon. And even if you can show your share dialog you wont be able to prefil any data
I am using general share intent for sharing news link containing image as well with other social sharing application installed in my phone.
The general share code is:
twitter.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
if (Utils.isNetworkAvailable(NewsDetailed.this)) {
// TODO Auto-generated method stub
Intent sendIntent = new Intent();
Intent i = getIntent();
sendIntent.setAction(Intent.ACTION_SEND);
String Title = i.getStringExtra("title");
String id = i.getStringExtra("id");
sendIntent.putExtra("android.intent.extra.TEXT", "http://www.mywesite.com/?p="+id);
sendIntent.setType("text/plain");
startActivity(sendIntent);
}
else{
showToast("Can't Post in Offline mode");
}
}
});
this code works fine for google plus, twitter, pintrest, umano etc etc..
If I want to share my news with Facebook it also works fine for news having images attached as well.
But if there is no image attached with the news, it picks an image without any criteria from the shared web link instead of picking the default image. However if the same link is shared with other social share apps it works fine and picks the default image.
if anybody has any idea as to how to fix this Facebook issue, please let me know. My application is published on google play store https://play.google.com/store/apps/details?id=com.Almuqeet.risingkashmir.
I want to share my android application link on simple button click to facebook as well as twitter.
basically I want to share some custom text and my application link of market.
So what i have to do to achieve this?
Any suggestion will be appreciated.
String message = "Text I want to share."
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("text/plain");
share.putExtra(Intent.EXTRA_TEXT, message);
startActivity(Intent.createChooser(share, "Title of the dialog the system will open"));
As documented in the answer found at Android - Share on Facebook, Twitter, Mail, ecc
btnShare = (Button)findViewById(R.id.btnShare);
btnShare.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plan");
String sharBody = "Body";
String shareSub = "Subject";
intent.putExtra(Intent.EXTRA_SUBJECT,shareSub);
intent.putExtra(Intent.EXTRA_TEXT,shareSub);
startActivity(intent.createChooser(intent,"Share Using")); }
});
}
Add your custom things in Subject.
Solution
1.I f you wan to share you application link from your android application to
facebook, twitter and any other social media.
So you want to follow these library
implementation 'com.github.premsingh8171:updateappOnplayStore:1.0.0'
repositories {
maven { url 'https://jitpack.io'
}
There are three method available for App rating, share app any other social media and Update app version.
More details follow link: https://github.com/premsingh8171/updateappOnplayStore
I have this code for sharing an app on facebook but when i share it it puts right links but wrong picture of the app
Button bShare = (Button) findViewById(R.id.button7);
bShare.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
final Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, "https://play.google.com/store/apps/details?id=com.myglobaljournal.christmascarol");
startActivity(Intent.createChooser(intent, "Share with"));
You can use the Debug tool to check how facebook "sees" this url.
From the result you can see that there are no og meta tags defined and so facebook probably takes a random picture from the content.
Edit
Facebook uses the open graph meta tags to extract info which is then used to render the share stories on the facebook experience.
You can see an example in the archived version of the Open Graph protocol, the new version uses the tags there but it's too complicated to your needs.
The only question is: can you any control over the output of the google play store for your app?
My guess is that you can't, and if you look at other examples (such as instagram or opera mobile) the image also appears random.
hi everybody i've a little problem..i'm trying to share a text using google plus app, but the lastest version give me a problem.
when i call with an intent "com.google.android.apps.plus", android display me this dialog
so if i choose the first one, text will be shared correctly, but the second one do nothing.
if the app is not intalled i redirect the user to the market, at g+ download page (this work fine)
if (v == plus) {
social(2);
targetedShareIntent.putExtra(
android.content.Intent.EXTRA_TEXT, user);
targetedShareIntent
.setPackage("com.google.android.apps.plus");
startActivity(targetedShareIntent);
}
"v" is a button and social check if app is installed
any sugestion?
both options open google+ application?
I suppose show two options because google+ app have two activities with category.LAUNCHER.... the app and the chat app
PSDT: sorry for my bad english!
I was able to get the G+ dialog to launch with the following code (after querying the package manager to make sure the app was actually installed and passing in the currentContext as a parameter):
Intent appIntent = new Intent(Intent.ACTION_SEND);
String shareText = "Share text goes here";
appIntent.setType("text/plain");
appIntent.putExtra(Intent.EXTRA_TEXT, shareText);
//Filters so only the G+ app will launch
appIntent.setPackage("com.google.android.apps.plus");
try {
currentContext.startActivity(appIntent);
} catch (android.content.ActivityNotFoundException e) {
Log.d(e.getMessage());
}
Drove me bananas figuring this out, so I figured I'd try to save someone else the hassle.