Zubair Akber
Zubair Akber

Reputation: 2828

Unable to open file for sharing from Bluetooth from external storage

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" />

Upvotes: 0

Views: 259

Answers (2)

Quick learner
Quick learner

Reputation: 11467

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

Upvotes: 3

Exception
Exception

Reputation: 2323

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

String sharePath = Environment.getExternalStoragePublicDirectory
        (Environment.DIRECTORY_PICTURES) + "/Aaa.jpg"

Upvotes: 2

Related Questions