How to send message through dialog box?
In my application I am clicking one share image button and four options facebook, twitter, mail and messaging are showing through alert Dialog box. I want to send message throuh fourth option(Messaging). How to do that. I have created dialog box like this. What will be the code to send the message to any mob no.
Here is my code.....
sharebuton.setOnClickListener(ne开发者_如何转开发w View.OnClickListener() {
@Override`enter code here`
public void onClick(View v) {
// TODO Auto-generated method stub
final CharSequence[] items = {"Facebook","Twitter", "E-Mail", "Messaging"};
AlertDialog.Builder builder = new AlertDialog.Builder(ProgramInfoActivity.this);
builder.setTitle("Share the Program");
builder.setItems(items, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
//Toast.makeText(getApplicationContext(), items[item], Toast.LENGTH_SHORT).show();
}});
AlertDialog alert = builder.create();
alert.show();
}
});
You can use default share Intent.
Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
shareIntent.setType("text/plain");
shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "message subject");
shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, "text");
startActivity(Intent.createChooser(shareIntent, "Pick a Share method"));
精彩评论