1

使用此代码通过创建选择器共享音频文件但不起作用...

公共类 ActionDialog 扩展 Dialog {

static String sSongTitle="";
static String sSongPath = "";
static File fSongFile ;

public ActionDialog(final Context context, Message response) {
    super(context);

    // Inflate our UI from its XML layout description.
    setContentView(R.layout.after_save_action);

    setTitle(R.string.alert_title_success);

    ((Button)findViewById(R.id.button_share))
    .setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                Uri StringUri = Uri.fromFile(new File(sSongPath)); 
                Intent intent = new Intent(android.content.Intent.ACTION_SEND, StringUri);
                Intent in = new Intent(android.content.Intent.ACTION_SEND, StringUri, context, null);
                intent.setType("audio/*");
                startActivity(Intent.createChooser(in, "select any from the list:"));//getting error here as create method startActivity(Intent)

            }
        });
}

}

4

2 回答 2

0

您的 Intent 是 Intent 不是 ishare Uri 是 stringUri 但您提到 ed 作为 StringUri .. 您可以发布整个代码 .. 以查看错误(如果有)

于 2013-10-29T09:18:17.817 回答
0

看到这个代码

@覆盖

protected void onCreate(Bundle savedInstanceState)

{

    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    ((Button) findViewById(R.id.button_share))
            .setOnClickListener(new View.OnClickListener() {
                public void onClick(View view) {
                    Uri stringUri = Uri.fromFile(new File(""));
                    Intent sendIntent = new Intent();
        sendIntent.setAction(Intent.ACTION_SEND);// intent for sharing
        sendIntent.putExtra(Intent.EXTRA_TEXT, stringurl);
        sendIntent.setType("audio/*");
        sendIntent.putExtra(Intent.EXTRA_SUBJECT, StringTitle);
        startActivity(sendIntent);// getting error
                                                            // as create
                                                            // method
                                                            // startActivity(Intent)
                }
            });

}
于 2013-10-29T09:50:32.610 回答