Connect android device to pc with usb cable

Connect android device to pc with usb cable

For recovering deleted, lost or formatted files (photos, videos, music) from your Android devices with any Photo Recovery software, you must connect your devices with PC in USB mode debugging. However, some Android users don’t know how to do this. Here are some tips to help you connect different version Android devices to PC with USB Mass Storage Mode.

Click to watch the video tutorial here.

  • How to use USB Mass Storage mode in Android 2.1-2.3.7

If you use Android 2.1-2.3.7 devices like Sony Xperia Samsung Galaxy Note, Samsung Galaxy S/S2, Motorola Droid RAZR, Droid 4, LG Optimus L3, HTC Rezound, HTC Sensation, HTC Desire, Kindle Fire, etc, follow simple instructions to connect your device in the mass storage mode.

1. Turn on USB debugging by click Menu > Setting > Applications > Development > USB debugging

2. Plug the supplied USB cable into your PC and connect it to your device. A USB icon will appear in the status bar when the device has been recognized.

3. In the main screen of your Android device, use your finger to pull down the top status bar. Then touch USB Connected.

4. Touch Connect USB storage.

Then tap “Ok“. When the green Android icon turn orange, the phone is now in USB Mass Storage mode and should now appear as USB disk drives in “Devices with Removable Storage” and be assigned drive letters.

  • Connect Android 4.0-4.1.2 device in USB mass storage mode

For Android 4.0-4.1.2 devices such as Samsung Galaxy S/S2/S3 or Nexus, HTC Desire X/V/C, HTC One X/V/S, LG Optimus L5/7/9, Optimus G, Motorola Droid RAZR, Sony Xperia V/T, Kindle Fire HD, etc, you can connect them to PC in USB debugging mode with the below guide.

Galaxy S2 (Android 4.0) as example.

1: Open the “Setting” > “More…”

2: Search then Tap on “USB utilities

3: Check the option: “Connect Storage to PC

Then plug the USB cable into the device and connect to your computer. The “USB connected” screen with the large green Android icon will appear. Tap on “Connect USB storage“. A confirmation dialog box will appear. Tap “OK“. The green Android icon will turn orange, indicating that the phone is now in USB Mass Storage mode and should now appear as USB disk drives in “Devices with Removable Storage” and be assigned drive letters.

  • Turn on USB Mass Storage mode in Android 4.2 or later versions Android 6/7/8

You will be dismayed to see that there is no USB Debugging option in Android 4.2 or the latest Android 6, Android 7, Android 8 smartphone or tablets like Nexus 4, Nexus 5X/6P, Google Nexus 10, Samsung Galaxy S8/S7/S4, Galaxy Note 5, Huawei Mate 10/9, Huawei Honor 9, Xiaomi Mi6, Mi 5X, Mi Mix 2, Redmi 5X, Sony Xperia Z5/M5, LG G5, HTC One M9/M8, etc. Here is a way to turn it on since it is very well hidden!

Читайте также:  Андроид студио работа с bluetooth

1: Go to Settings -> About Phone/Tablet or Settings -> About Phone -> Software info
2: Go to “Build Number” at the end of the Scroll list.
3: Tap on “Build Number” repeatedly (7 times). On your third tap you should see message indicating that you only have 4 more taps to go to ‘become a developer’. Keep tapping until you are a developer.

4. Now Developer Option will be included in setting list of yours now. Go to “Develop Options” to check USB debugging > OK. Done.

Tip: When you connect your Android to computer for the first time, you can check “Always allow from this computer” with the pop up before clicking “OK” to finish.


Tip: For some android devices, you also need to select mode “Photos” or “Files” in “Notifications”.

And then you can see your andriod phone icon in PC. “Computer”-”Portable devices” as below.

Notes:
1. After debugging, you connect android device to computer with the factory USB cable at the first time, Windows will look for and install the associated driver automatically. Please waiting a moment for the drive installing, then you can get a pop-up interface and a USB icon will appear in the PC status bar.
2. If your android device doesn’t work as USB debugging mode in PC, try to check and change the USB cable.
Some USB cables only can be used to charge, but can’t to transmit data. So use the factory USB cable or that supports USB data transfers!

After connecting your device to PC with USB Mass Storage mass, or connect the memory card through your computer’s card reader. Then you can recover deleted photos, videos from devices.

Note: If you still can’t connect your Android devices to PC with USB debugging mode with this method, you should search an android USB Drive apps in official site of your phone. For example: Samsung Android USB Driver or install the Android Debug Bridge, etc.

Источник

How to Connect your Android Device with a USB Cable.

Introduction

As well as connecting your Android device to Droid Transfer over your local WiFi network, you can also connect your Android device to your computer using a USB cable.

To do this — you need to change some of the settings on your Android device so that Droid Transfer and Transfer Companion (running on your Android device) can communicate. This support article shows you how.

Enabling Developer Options on your Android Device.

You need to change some settings on your Android device so that «Developer Mode» is enabled.

  1. Open your device settings and choose «About phone», «About device» or just «About».
  2. Look for the entry «Build Number», or «Build Version». This entry may be under a further sub-menu called «Software Information» or «Software Info» on some devices.
  3. Tap the «Build Number» entry five or six times. (No, really!)
    Your device will show you how many taps are required to enable Developer Mode. When done your device will have Developer Mode enabled.
  4. Go back to your main Settings menu — scroll down to the bottom, you should see a new entry called «Developer Options».
Читайте также:  Начала электроники для андроид

Congratulations! You’re now a developer! 😉

Enable USB Debugging.

Just a couple more settings to change.

  1. Tap to open «Developer Options»
  2. Make sure «Developer Options» is set to ON.
  3. Scroll down to «USB Debugging» and make sure that is enabled also. If it isn’t, slide the toggle switch to the right to enable it.
  4. Depending on your Android device — a window may pop up on your phone asking you to verify that you want to enable USB Debugging. Click OK or Apply to allow USB Debugging to become enabled.

Download Transfer Companion to your Android Device.

Download Transfer Companion to your Android device from the Google Play Store. You need to be running at least version 1.58 of Transfer Companion — so check for updates if you have previously downloaded Transfer Companion to your Android device.

Download Droid Transfer to your PC.

On your Windows PC, go to this address to download Droid Transfer.

Run Droid Transfer on your PC

Run Droid Transfer on your PC and when you see the connect screen:

Connect your Android device to your PC with a USB cable. Depending on your device, your phone may request permission for it to communicate with your PC.

Click OK or Allow on any prompts showing on your Android Device.

When Droid Transfer detects your device, it will launch Transfer Companion on your Android device and begin to load your phones data through the USB cable.

Connection should now made between Droid Transfer and Transfer Companion and you can start managing and copying your Android Phone content using Droid Transfer on your PC.

If you’re having troubles, check out our USB connection troubleshooting tips which will help you resolve any issues.

Don’t forget to like & share with your friends!

Read Next: Troubleshooting Droid Transfer WiFi Connection >

Источник

Работа с устройствами USB в Android

В недавней статье на Geektimes в комментариях возник вопрос о поддержке в ОС Android периферии, подключенной к шине USB. Действительно, большинство вендорского ПО, к примеру, для работы с принтерами и МФУ, поддерживает только подключение по сети. Однако это не означает, что в самой ОС Android нет такой возможности — это означает лишь то, что большинство устройств не имеют полноценного USB хоста, и далеко не все имеют поддержку OTG. По сети же могут работать абсолютно все без исключения.

Большинство устройств на Android при наличии порта OTG поддерживают на уровне системы (ядра Linux или стандартных компонентов Android) следующие классы устройств:

  • Устройства ввода — клавиатуры, мыши, джойстики (HID)
  • Накопители (Mass Storage)
Читайте также:  Все для украшения андроид

Несколько реже:

  • Сотовые модемы
  • Сетевые адаптеры
  • Вебкамеры

Хабы поддерживаются при наличии полноценных хост-портов, но не поддерживаются на портах OTG.

Подробнее список устройств, поддерживаемых на уровне ядра Linux, можно получить в sysfs:

$ ls /sys/bus/usb/drivers

Если же модуль в принципе доступен в исходниках ядра Linux, но не включен в Android — не стоит рассчитывать на то, что его получится собрать и расставить на все целевые системы.

Однако, начиная с Android 3.1 (API 12), в системе содержатся средства, достаточные для поддержки на уровне приложения любой USB периферии. Данные средства описаны в разделе USB Host руководства по Android API. Здесь же я хочу привести примеры реальной работы с некоторыми видами устройств.

Права доступа

Как и для прочих действий, Android требует, чтобы приложение получило разрешение на доступ к USB периферии. Существует 2 способа получить такое разрешение:

  • Задекларировать список устройств в AndroidManifest
  • Явно показать пользователю диалог “разрешить”

Поскольку для моих задач лишние вопросы к пользователю были нежелательны, я использовал первый способ.

Итак, нам необходимо добавить в манифест следующее:

А в res/xml/device_filter.xml вписать следующее:

Отмечу, что хотя общепринято указывать VID:PID в 16-ричной системе счисления, здесь они должны быть указаны в десятичной. В документации заявляется, что возможно указание только класса, без VID и PID, но у меня это не стало работать.

Принтеры

На примере принтера я покажу, как непосредственно использовать API android.hardware.usb. На уровне передачи данных все принтеры поддерживают стандартый класс USB устройств:

Класс предельно простой. В рамках этого класса устройство должно поддерживать:

  • Обязательный bulk out endpoind для отправки данных на принтер
  • Опциональный bulk in endpoind для получения статуса принтера
  • 3 управляющих запроса

Код, приведенный ниже, предоставляет функциональность, аналогичную устройству /dev/usb/lp в Linux. Далее нам нужен фильтр, преобразующий исходный документ в пакет данных, понятный конкретной модели принтера. Но это тема иной статьи. Как один из вариантов — можно собрать ghostscript с помощью NDK.

Для работы с устройством нам в первую очередь нужно:

1. Найти устройство. В примере для простоты я ищу первый попавшийся:

2. Получить endpoint’ы:

3. Непосредсвенно открыть устройство:

4. После этого мы можем читать и писать в устройство:

5. По завершении работы — закрыть устройство:

Преобразователи USB-Serial

В отличие от притеров, преобразователи USB-Serial гораздо менее стандартизированы. Существует несколько распространенных чипов, для которых существенно отличается установка параметров последовательного порта — битрейта, чётности и проч. К счастью, есть библиотека github.com/mik3y/usb-serial-for-android, поддерживающая практически все существующие чипы. Библиотека полностью скрывает USB API, сводя все необходимые действия к минимуму вызовов с минимумом параметров.

1. Найти и открыть устройство:

2. Установить параметры последовательного порта:

3. Читать и писать в порт:

4. По завершении работы — закрыть порт:

Резюме

Надеюсь, что мне удалось показать, что работа с USB периферией достаточно проста и логична. Безусловно, реализация протоколов некоторых конкретных устройств не блещет простотой — но это проявится в любой системе в одинаковой степени.

Все приведенные примеры я взял из реального проекта, лишь исключил очевидные проверки, оставив только ключевые строки.

Источник

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