什么可能导致共享Android应用程序的问题?

时间:2014-02-19 19:05:10

标签: java android

我正在开发应用程序中的一个选项,以便与人共享下载链接。以下是我所拥有的。有什么问题?

public void onClick(View v) {
    Intent intent = new Intent();
    boolean start = true;
    String test = "google.com";

    switch (v.getId()) {
    (...)
    case R.id.share:
        start = false;
        Intent send = new Intent();
        send.setAction(Intent.ACTION_SEND);
        send.putExtra(Intent.EXTRA_TEXT, test);
        send.setType("text/plain");
        startActivity(send);
        break;
    }

    if (start)
        startActivity(intent);  //line 135
}

在切换结束时,如果start为false,则不会执行startActivity(),因为它是在共享的情况下执行的。但是,当我在应用程序中显示时,我得到以下错误...

 02-19 11:55:01.630: E/AndroidRuntime(27279): android.content.ActivityNotFoundException: No Activity found to handle Intent {  }

这引用第135行,这将是第二个“startActivity()”。有谁知道发生了什么事?

3 个答案:

答案 0 :(得分:0)

当您发送Intent send时,未设置意图。

为什么你已经完成了第135行,因为你已经在startActivity(send)发送了电子邮件?

答案 1 :(得分:0)

更改第135行
startActivity(intent);  //line 135

startActivity(send);  //line 135

答案 2 :(得分:0)

当你到达if(start)块时,从未使用action和其他参数正确初始化intent。我不知道你想要完成什么,但你需要这样的东西:

if (start) {
    // Set appropriate parameters here...
    intent.setAction(Intent.ACTION_SEND);
    intent.putExtra(Intent.EXTRA_TEXT, test);
    intent.setType("text/plain");

    startActivity(intent);  //line 135
}
相关问题