Showing posts with label android shareIntent. Show all posts
Showing posts with label android shareIntent. Show all posts

Thursday, January 19, 2012

sharing content on web using shareIntent in android



When you are click on image button than sharing dialog is open.
code here..........
shareButton.setOnClickListener(new OnClickListener() {


@Override
public void onClick(View v) {
Toast.makeText(mcontext,"click", Toast.LENGTH_SHORT).show();


//create the intent

Intent shareIntent = 
 new Intent(android.content.Intent.ACTION_SEND);

//set the type
shareIntent.setType("text/plain");

//add a subject
shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, 
 "Insert Subject Here");

//build the body of the message to be shared
String shareMessage = "Insert message body here.";

//add the message
shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, 
 shareMessage);

//start the chooser for sharing
startActivity(Intent.createChooser(shareIntent, 
 "Insert share chooser title here"));


}
});