Sending file via bluetooth android

how to send media files via bluetooth in android

I have a requirement. I need to build an app, which uses Bluetooth to send media files like songs, images etc to another device. I have no knowledge about how to do this. Can anyone assist from scratch to make me get a rough idea about how getting this done. Sample code would be very helpful. Thanks.

2 Answers 2

I think you should read this document once .

In this example they are sending PDF file form SD Card Path but i think you can also send media file like audio and video as same.

private void envio() < Intent intent = new Intent(); intent.setAction(Intent.ACTION_SEND); intent.setType("text/plain"); File archivo=new File(_path); intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(archivo) ); ///////////////////pakage manager PackageManager pm = getPackageManager(); ListappsList = pm.queryIntentActivities( intent, 1); if(appsList.size() > 0) < //Toast.makeText(this,"su telefono no cuenta con aplicacion de intercambio de datos",Toast.LENGTH_LONG).show(); >//selleccionar la aplicacion de bluetooth String packageName = null; String className = null; boolean found = false; // BluetoothAdapter.checkBluetoothAddress(""); for(ResolveInfo info: appsList) < packageName = info.activityInfo.packageName; if( packageName.equals("com.android.bluetooth"))< className = info.activityInfo.name; found = true; break;// found >> if(! found) < Toast.makeText(this,". ", Toast.LENGTH_SHORT).show(); // exit >intent.setClassName(packageName, className); startActivity(intent); > 

Linked

Hot Network Questions

Subscribe to RSS

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

Site design / logo © 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2023.7.14.43533

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.

Источник

How to send files via Bluetooth on Android

This article will be useful for people, who have recently started to use Android device or decided to use more of its useful features. We will tell you how to transfer files via Bluetooth on Android from the gallery or file manager.

The comfortability of Bluetooth

If you decided to share some files from your smartphone or tablet, the easiest way to do this is via the Bluetooth module. Almost all gadgets support this method of file sharing, and such a procedure is carried out in just a couple of clicks.

Now we will show how to send files via Bluetooth from different applications.

While writing this article, we used Android 6.0.1 device with a stock photo gallery. If you have another Android version or you use the program with a different design, do not worry. The principle will be the same everywhere. You will have to find similar buttons, and everything will work.

Let us consider how to send files via Bluetooth on Android via standard program for viewing photos and videos.

  1. Open the gallery.
  2. Open the image or video you want to send.
  3. Press the «Share» button, which looks like three nodes.
  4. In the pop-up menu, click «Bluetooth». If the wireless module was not previously enabled, you will see the message saying that it is necessary to turn it on. Confirm this action. Next, you will see the window with the search bar, where the available devices will be displayed. Press the name of the device, to which you want to send the file via Bluetooth on Android.
Читайте также:  Smart watch bluetooth call

It may happen, that after the sixth paragraph the data will not be sent, and you will see the «not sent» message. This is because some devices do not accept files from unknown sources (the so-called protection). For successful sending, you will need to pair the devices.

In order to pair the devices, you will need to perform the following actions on them:

  1. Open the settings.
  2. Choose «Bluetooth».
  3. If the wireless module is not enabled, activate it by tapping the switch at the top right of the display. After these operations, the wireless module will be activated on both devices.
  4. After that, if you have the Android Marshmallow version, the discoverable mode will be enabled automatically. If you have the 4.х version of the OS, you will need to activate this function on one of the devices by clicking the checkbox next to the name of the device.
  5. On the second device, scan the network by clicking «Search» or «Refresh», depending on the version of the OS.
  6. In the list of found devices, find the name of the desired device and choose it to create a pair.
  7. On this device, you will receive the confirmation request. Accept it.

After these actions, resend your file.

Sending via the file manager

It may happen that you will need to send any document. You will not be able to do it from the gallery. However, you can use the file explorer.

We will use the third-party file manager – ES Explorer . If you wish, you can download it to your device and repeat all the following actions.

On the other hand, you can try to repeat similar steps in your standard file explorer.

After downloading and installing the ES Explorer on the phone, follow these steps:

  1. Open the explorer, find the desired file and select it by making a long tap.
  2. Press «Additional» (the rightmost button at the top).
  3. Click «Share».
  4. Choose «Bluetooth».
  5. Further, everything is performed similarly, as it was done in the gallery. You will need to click the name of the recipient to start sending.

How to send files via Bluetooth on Android: Video

Top apps for sending Files

[rBlock name=after_video return=1]

Источник

Send file using android bluetooth?

Is there any way I can send files using Android’s internal Bluetooth to other devices? Please provide an example.

2 Answers 2

This is a small function that you can use

/** * Method to share data via bluetooth * */ public void bluetoothFunctionality() < String path = Environment.getExternalStorageDirectory() + "/" + Config.FILENAME; File file = new File(path); Intent intent = new Intent(); intent.setAction(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file)); startActivity(intent); >

This method will send file to another device using default device bluetooth functionality. Before you do this you have to first paired the device this is limitation. to send different types of file you have to just change MIME type in set type method

Читайте также:  What is it called bluetooth

In your manifest file you have to add two permissions like

It’s weird that Android has no explicit OBEX api. Anyway, take a look at this project :

Or alternatively you can use this solution

BluetoothDevice device; String filePath = Environment.getExternalStorageDirectory().toString() + "/file.jpg"; ContentValues values = new ContentValues(); values.put(BluetoothShare.URI, Uri.fromFile(new File(filePath)).toString()); values.put(BluetoothShare.DESTINATION, device.getAddress()); values.put(BluetoothShare.DIRECTION, BluetoothShare.DIRECTION_OUTBOUND); Long ts = System.currentTimeMillis(); values.put(BluetoothShare.TIMESTAMP, ts); Uri contentUri = getContentResolver().insert(BluetoothShare.CONTENT_URI, values); 

Источник

Easily share files between Android and desktop via Bluetooth

If you’re looking to share files between your Android device and a desktop PC, Jack Wallen shows you how.

We may be compensated by vendors who appear on this page through methods such as affiliate links or sponsored partnerships. This may influence how and where their products appear on our site, but vendors cannot pay to influence the content of our reviews. For more info, visit our Terms of Use page.

Bluetooth can be a remarkable technology. With it, you can pair devices together for hands- and wire-free usage and an amazing assortment of peripherals. But one of the most overlooked uses of Bluetooth is file sharing. If you happen to have a desktop or laptop with a Bluetooth device, you can easily share files between your Android smartphone or tablet and that desktop. Let me show you how.

The desktop and device you have will dictate how you accomplish this tasks. Which direction you share files will also impact the process. I’m going to show you how to share files from a Verizon-branded Droid Turbo to an Ubuntu 14.10 desktop — and vice versa.

There is one caveat to working with Bluetooth on Ubuntu Linux — you need to install a small app called Blueman from the standard repositories (it can be installed from the Ubuntu Software Center). With this app, you can then set a device as trusted so files can be successfully shared (otherwise, they will fail every time).

Pairing

Before you share, you have to pair. To do this, first make sure Bluetooth is enabled on your desktop. Then, from your Android device, go to Settings | Bluetooth, and locate the listing for your desktop. Tap that entry (Figure A), and wait for the connection to be established (you may have to enter a security key for your desktop’s Bluetooth device — usually either 0000 or 1234).

Available Bluetooth connections.

Now that you’re connected, you can start sending and receiving files.

From Android to desktop

There are two ways to successfully share files from Android to your Bluetooth-enabled desktop:

The simplest method is using the built-in system. However, if you happen to require sharing a file that doesn’t allow sharing through the built-in system, you may have to depend on a third-party. One very well designed solution is Bluetooth File Transfer. With this application, you can connect to your desktop and, using the built-in file manager, transfer any file to your desktop.

First, the built-in sharing system. I’ll demonstrate by sending an image from with the Photos app. Here’s how:

  1. Open Photos
  2. Locate and open the photo to be shared
  3. Tap the Share icon
  4. Tap the Bluetooth icon (Figure B)
  5. Tap to select the Bluetooth device to share the file to
  6. When prompted on the desktop, tap Accept to permit the sharing
Читайте также:  Подключить гарнитуру блютуз самсунг галакси

Selecting Bluetooth as your sharing option.

The file should show up on your user’s home directory (in the case of Linux, that will be ~/).

Let’s say you have a file that doesn’t include the built-in sharing menu. For that, you’ll need to make use of a third-party solution. Let me walk you through the process of sending a file, via Bluetooth, using Bluetooth File Transfer. Install the app from the Google Play Store with the usual installation steps. Once the app is installed, use the following steps to send a file via Bluetooth:

  1. Open the app
  2. From the main window, tap on the Bluetooth tab
  3. From the Bluetooth tab, tap the desktop you want to share with (Figure C)
    Figure C
  4. When prompted, select the protocol to use for the transfer (File Transfer Protocol — FTP, Object Push Profile — OPP, or Phone Book Access Protocol — PBAP)
  5. Once the connection is made, tap the local files tab
  6. Navigate to the file to send
  7. Select the file(s) to be shared (Figure D)
    Figure D
  8. Long-press one of the files and tap Upload
  9. When prompted on the desktop, tap Accept
  10. Wait for the files to transfer (Bluetooth is a bit slow)

From desktop to Android

This process is actually a bit easier but will drastically vary, depending on the operating system you’re using. However, most platforms have developed a very user-friendly process for sending files via Bluetooth. I’ll demonstrate using Blueman on Ubuntu 14.10, which should illustrate how easy sharing files can be. Here’s the process:

  1. Open up the Bluetooth app (in this case, Blueman)
  2. Set the device to share files as trusted (right-click the device and select Trust, as shown in Figure E)
  3. Right-click the trusted device, and select Send a File
  4. Locate and select the file to be sent, and click OK
  5. If prompted on your smartphone, tap to allow the transfer

Sharing a file to your smartphone with Blueman.

As I mentioned, depending on your platform, the process will vary — but it shouldn’t be any more difficult than what I outlined above.

Sharing files between your Android device and your desktop doesn’t have to be a challenge. If you happen to have a Bluetooth adapter on your desktop, you can make this process even easier by taking advantage of the Android built-in sharing system.

How do you share files between your Android device and your desktop? Share your experience in the discussion thread below.

Person using a laptop computer.

Subscribe to the Daily Tech Insider Newsletter

Stay up to date on the latest in technology with Daily Tech Insider. We bring you news on industry-leading companies, products, and people, as well as highlighted articles, downloads, and top resources. You’ll receive primers on hot tech topics that will help you stay ahead of the game.

Also See

Источник

Оцените статью
Adblock
detector