alertdialog分享到Facebook或Twitter等社交网络

时间:2013-07-16 13:46:08

标签: android facebook twitter share alertdialog

完成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();      

    }

1 个答案:

答案 0 :(得分:0)

阅读this。谷歌拥有几乎所有Android开发方面的文档培训库。