无法通过蓝牙共享....文件未发送错误

Cannot share via bluetooth....file not sent error

这是我的代码:

List<Intent> targetedShareIntents = new ArrayList<Intent>();
Intent sharingIntent = new  Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
PackageManager pm =getApplicationContext().getPackageManager();
List<ResolveInfo> activityList =   pm.queryIntentActivities(sharingIntent, 0);

for(final ResolveInfo app : activityList) {
    String packageName = app.activityInfo.packageName;
    Intent targetedShareIntent = new Intent(android.content.Intent.ACTION_SEND);
    targetedShareIntent.setType("text/plain");
    targetedShareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "share");

    if(TextUtils.equals(packageName, "com.facebook.katana")){
        targetedShareIntent.putExtra(android.content.Intent.EXTRA_TEXT, "http:your link");
    } else {
        targetedShareIntent.putExtra(android.content.Intent.EXTRA_TEXT,  Fragmentactivity.songpaths.get(indexfordelete));
        targetedShareIntent.putExtra(Intent.EXTRA_SUBJECT, " Thirukural Version 1.7.2 !");
    }
    targetedShareIntent.setPackage(packageName);
    targetedShareIntents.add(targetedShareIntent);
}

Intent chooserIntent = Intent.createChooser(targetedShareIntents.remove(0), "Share Application  your app name ");
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, targetedShareIntents.toArray(new Parcelable[]{}));
startActivity(chooserIntent);

我想先通过蓝牙分享它,但它不起作用。我收到错误 ~File not sentFragmentactivity.songpaths.get(indexfordelete) 是我要分享的文件路径。

在此处尝试此代码我正在分享文本,您可以分享您想要的内容:

List<Intent> targetedShareIntents = new ArrayList<Intent>();
Intent sharingIntent = new      Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
PackageManager pm =v.getContext().getPackageManager();
List<ResolveInfo> activityList =   pm.queryIntentActivities(sharingIntent, 0);

for(final ResolveInfo app : activityList) {
    String packageName = app.activityInfo.packageName;
    Intent targetedShareIntent = new Intent(android.content.Intent.ACTION_SEND);
    targetedShareIntent.setType("text/plain");
    targetedShareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "share");

    if(TextUtils.equals(packageName, "com.facebook.katana")){
        targetedShareIntent.putExtra(android.content.Intent.EXTRA_TEXT, "http:your link");
    } else {
        targetedShareIntent.putExtra(android.content.Intent.EXTRA_TEXT, strLink);
        targetedShareIntent.putExtra(Intent.EXTRA_SUBJECT, " app version");
    }
    targetedShareIntent.setPackage(packageName);
    targetedShareIntents.add(targetedShareIntent);
}

Intent chooserIntent = Intent.createChooser(targetedShareIntents.remove(0), "Share Application  your app name ");
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, targetedShareIntents.toArray(new Parcelable[]{}));
startActivity(chooserIntent);