0

I am trying to use intent for sharing a file using bluetooth but i don't know why is it showing me toast "Unable to open file for sharing" i have tried it on different files as well but it do the same, i am sharing my code and permissions i have used in manifest ...

    String sharePath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/Pictures/Aaa.jpg";
    Uri uri = Uri.parse(sharePath);
    Intent share = new Intent(Intent.ACTION_SEND);
    share.setType("image/*");
    share.putExtra(Intent.EXTRA_STREAM, uri);
    startActivity(Intent.createChooser(share, "Share Sound File"));

permissions i have addedso far

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
Quick learner
  • 10,632
  • 4
  • 45
  • 55
Zubair Akber
  • 2,760
  • 13
  • 30

2 Answers2

3

try This

File sourceFile = new File("//mnt/sdcard/TviderFB.apk"); 
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
Intent.setType("image/jpeg"); 
intent.putExtra(Intent.EXTRA_STREAM,Uri.fromFile(sourceFile));
startActivity(intent);

Or Read this carefully and implement this How to send file using bluetooth on android programatically?

Or Read This Tutorial to share via bluetooth http://kpbird.blogspot.in/2011/04/android-send-image-via-bluetooth.html

And Do not Forget to Declare Permissions in the manifest

Community
  • 1
  • 1
Quick learner
  • 10,632
  • 4
  • 45
  • 55
2

If image is in picture folder then path will be like this

String sharePath = Environment.getExternalStoragePublicDirectory
        (Environment.DIRECTORY_PICTURES) + "/Aaa.jpg"
Exception
  • 2,273
  • 1
  • 24
  • 42