Sunday, September 29, 2013

Connect Android Nexus 4 Android 4.3 to openSUSE 12.3

So totally pleased about today's accomplishment of connecting the Android to Linux openSUSE 12.3. 

Easy when you know how.

The BLUF is gmtp and adb but there are several other steps.

The first problem was that the Android (LGE Nexus 4) was not being recognized as a Media Transfer Protocol (MTP) device.

You have to activate Developer Settings in the 'droid to fix this. 

Here is how:

  1. Go to the settings menu, and scroll down to "About phone." Tap it.
  2. Scroll down to the bottom again, where you see "Build number."
  3. Tap it seven (7) times. After the third tap, you'll see a playful dialog that says you're four taps away from being a developer. (If only it were that simple, eh?) Keep on tapping, and *poof*, you've got the developer settings back.

Intuitive, eh?

Anyhow, the next step is to change the mode. 

Go to the now visible {}Developer Options and make sure that
USB debugging
is checked. Now 
• Go up to the main Settings page
• Click Storage
• Click the three dot settings icon in the upper right hand corner
• Click on USB computer connection and choose Media device (MTP) instead of Camera (PTP).

Now, on the computer, install both gmtp and adb. Both are available under the respositories under openSUSE, but if you can't find them then google.

gmtp succeeds in waking up the system to the presence of an MTP device. Just plug in the 'droid. A window will pop up. Select "Open in File Manager" and you'll have an instance of konqueror open to

     mtp: Nexux 4

You can then manually drag and drop files back and forth if you open a second window in konqueror.

You need Android Debugging Bridge (adb) if you want to use BASH scripts to transfer files. adb is included in the openSUSE package android-tools.

This may help:

It just works. 

For example, issue the following terminal or script command after plugging in the 'droid to transfer a file to  the 'droid:

      adb push /data/finance/transactions/transactions.xls /sdcard/data/finance/

Or use the following to copy a batch of files from the 'droid:

      adb pull /sdcard/DCIM/Camera /data/action/latest/

The source in this case is not intuitive: initially I used .../Camera/* and it choked. But dropping the wildcard resulted in copying all files in .../Camera to the computer.

So YMMV, you may have to farkle with this.
Note that the first argument in the push statement or the second one in the pull statement is the fullpath_and_filename on the computer. The other argument substitutes


for the 'droid value seen in konqueror above of

      mtp:/Nexus 4/internal storage

So whatever 'droid path you wish to target that you see in konqueror is translated. 

For example:

      mtp:/Nexus 4/internal storage/data

in konqueror needs to be translated to


in a script.

The following script automates synchronizing selected files back and forth after doing all the foregoing:

#! /bin/bash
# Check for Android plugged in
  echo "Connect the Android."
  echo "Continue? (y|n):"
  read user
# If Android connected
  if [ "$user" == "y" ]; then
# Transfer to Android
  echo "Transferring transactions.xls to Nexus."
  adb push /data/finance/transactions/transactions.xls /sdcard/data/finance/
  echo "Transferring itinerary.xls to Nexus."
  adb push /data/info/itinerary/itinerary.xls /sdcard/data/info/
  echo "Copying latest photos to /data/action/latest"
# Transfer from Android
  adb pull /sdcard/DCIM/Camera /data/action/latest/
# Finish


Easy when you know how.

No comments: