【问题标题】:Unable to create content to send无法创建要发送的内容
【发布时间】:2012-05-05 15:52:02
【问题描述】:

我正在尝试通过蓝牙发送图像,我一直收到一条错误消息,提示无法创建要发送的内容

代码如下:

public void onClick(View v) {
    Intent i = new Intent(Intent.ACTION_SEND);
    i.setType("image/jpeg");     
    i.putExtra(Intent.EXTRA_STREAM, Uri.parse("/sdcard/test.jpeg"));  
    startActivity(Intent.createChooser(i, "Send Image")); // TODO Auto-generated method stub
}

非常感谢

【问题讨论】:

    标签: android image bluetooth


    【解决方案1】:

    我认为图片的路径不正确,试试这个:

    i.putExtra(Intent.EXTRA_STREAM, Uri.parse(Environment.getExternalStorageDirectory() + "/test.jpeg"));
    

    这里还有一个如何通过蓝牙发送文件的示例:

    Sending a File using Bluetooth OBEX Object Push Profile (OPP)

    【讨论】:

    • 我在上面使用的代码,不属于以编程方式传输图像??
    【解决方案2】:

    如果你想使用一个文件作为 uri 你需要添加file://

    Uri.parse("file:///sdcard/test.jpeg")
    

    Uri.fromFile(new File("/sdcard/test.jpg"));
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-10
      • 2021-02-20
      • 1970-01-01
      • 1970-01-01
      • 2018-01-20
      • 1970-01-01
      相关资源
      最近更新 更多