【问题标题】:share a zip file on bluetooth在蓝牙上共享一个 zip 文件
【发布时间】:2012-12-15 16:28:55
【问题描述】:

我在我的应用程序中创建了一个 Zip 文件,现在我想在 Android 手机中的其他应用程序上共享这个 zip 文件,例如蓝牙或 Gmail 或...。 我用这个:

Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM, zipName);
shareIntent.setType("*/*");
activity.startActivity(Intent.createChooser(shareIntent,activity.getResources().getText(R.string.send_to)));

zipname 是我的 zip 文件路径。 此代码通过按下按钮执行。将弹出一个包含所有应用程序的列表,但单击蓝牙只会关闭弹出窗口,没有其他内容!

为什么?请帮我。我需要打开蓝牙并打开蓝牙,....

【问题讨论】:

  • 文件 zipname 是否存在?其他应用是否有权访问该文件?
  • 是的,zip 文件存在,并且该文件位于文件夹的 sdcard 上,我认为这是可以访问的。如何检查?

标签: android android-intent bluetooth zip share


【解决方案1】:

我自己解决了,zipname 是文件的路径,但它需要是 uri,所以我使用了这个代码

shareIntent.putExtra(Intent.EXTRA_STREAM, uri.fromfile(new File(zipName)));

而不是

shareIntent.putExtra(Intent.EXTRA_STREAM, zipName);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-06-11
    • 1970-01-01
    • 1970-01-01
    • 2011-09-01
    • 1970-01-01
    • 2012-08-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多