使用意向并发送通过蓝牙发送文件并不在android系统4.2.2工作吗? [英] Sending File via Bluetooth using Intent Action SEND does not working in android 4.2.2?

查看:272
本文介绍了使用意向并发送通过蓝牙发送文件并不在android系统4.2.2工作吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用意向SEND共享的文件通过bluetooth.I这里加我的code。

I have used Intent-SEND to share the files via bluetooth.I have add my code here.

    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_SEND);       
    intent.setComponent(new ComponentName("com.android.bluetooth",
            "com.android.bluetooth.opp.BluetoothOppLauncherActivity"));

    intent.setType("text/plain");

    File file = new File(Environment.getExternalStorageDirectory()
            .getAbsolutePath() + "/Sample.txt");
     intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
    startActivity(intent);

这code未在Android版本4.2.2工作。当运行在android系统verison 4.2.2,得到这个异​​常code:

This code is not working in android version 4.2.2. While running this code in android verison 4.2.2 , getting Exception:

        android.content.ActivityNotFoundException: Unable to find explicit activity   class {com.android.bluetooth/com.android.bluetooth.opp.BluetoothOppLauncherActivity}; have you declared this activity in your AndroidManifest.xml?

但是,这code以下的Andr​​oid 4.2.X.工作正常为什么这个code未在安卓4.2.2工作?

But this code working fine in below android 4.2.X. why this code is not working in android 4.2.2?.

推荐答案

您可以通过这样的蓝牙共享文件:

You can share the file by bluetooth like this:

Intent sharingIntent = new Intent(Intent.ACTION_SEND);
Uri screenshotUri = Uri.parse(picURI);
File file = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/Sample.txt");

sharingIntent.setType("text/plain");
sharingIntent.setPackage("com.android.bluetooth");
sharingIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
startActivity(Intent.createChooser(sharingIntent, "Share file"));

这篇关于使用意向并发送通过蓝牙发送文件并不在android系统4.2.2工作吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆