完成alertdialog以显示来自edittext和listview所选项目的文本后,我想将结果alertdialog分享到facebook或twitter应用程序。我怎样才能做到这一点?我可以使用图书馆授权或类似的东西吗?谢谢
这是我的代码MainActivity.class,可以通过电子邮件分享。
@Override
public void onItemClick(AdapterView<?> adapter, View view, int position, long id) {
// TODO Auto-generated method stub
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
alertDialogBuilder.setTitle("Result");
final String alert1 = "First Name: " + etName1.getText().toString();
final Object alert2 = "Result: " + lv.getItemAtPosition(position);
alertDialogBuilder.setMessage(alert1 +"\n"+ alert2);
alertDialogBuilder.setCancelable(false)
.setPositiveButton("Yes",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int id)
{
String message = alert1 +"\n"+ alert2;
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("text/plain");
share.putExtra(Intent.EXTRA_TEXT, message);
startActivity(Intent.createChooser(share, "Select application to share your result"));
}
})
.setNegativeButton("No",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int id) {
dialog.cancel();
}
});
AlertDialog alertDialog = alertDialogBuilder.create();
alertDialog.show();
}