I am building android application now i already completed, but I want to add Share button in root activity that user can share my application(link to download from google market) to google+ , facebook, twitter and linkin.
How can i do it?
my code:
ImageButton sharingButton = (ImageButton) findViewById(R.id.share);
sharingButton.setLayoutParams(new ViewGroup.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
sharingButton.setImageResource(R.drawable.ic_share);
sharingButton.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v)
{
shareIt();
}
});
private void shareIt()
{
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, shareBody);
startActivity(Intent.createChooser(sharingIntent, "Share via"));
}
I tried this but doesn’t give me a result. Can you please help me?
regards,
if you prefere to do it by your self, with a library, you should use addThis :
http://support.addthis.com/customer/portal/articles/381271-addthis-for-android-quickstart-guide