开发者

Sending file using bluetooth in android [duplicate]

This question already has answers here: Android Emulator vs Real Device (7 answers) Closed 4 days ago.

I am developing an Android application which uses Android's Bluetooth implementation. I want to know whether Bluetooth can be tested in an Android emulator. Can the user send files from the A开发者_如何学Pythonndroid emulator using Bluetooth?


I used this in my app....

try {
    File myFile = new File("filepath");
    MimeTypeMap mime = MimeTypeMap.getSingleton();
    String ext=myFile.getName().substring(myFile.getName().lastIndexOf(".")+1);
    String type = mime.getMimeTypeFromExtension(ext);
    Intent sharingIntent = new Intent("android.intent.action.SEND");
    sharingIntent.setType(type);
        sharingIntent.putExtra("android.intent.extra.STREAM",Uri.fromFile(myFile));
    startActivity(Intent.createChooser(sharingIntent,"Share using"));
}
catch(Exception e){
    Toast.makeText(getBaseContext(), e.getMessage(),Toast.LENGTH_SHORT).show();
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜