Nexus 5X not detected in Windows

My Nexus 5 was working fine with my Windows 7 desktop, but when i plugged in a Nexus 5X (running Android 6.x) it was not detected at all (in Windows Explorer or adb). Installing drivers did not help, and the phone was detected fine on another Windows 7 computer. Here’s what fixed it – go into Device Manager and see if you have a ‘Portable Devices’ node. If you don’t, check to see if you have a ‘Android Device’ node. If so, try right clicking the child node and choosing ‘Update Driver Software’.

android-nexus5x-not-detected

For me, it found some random USB compatible device or something, and then the ‘Portable Devices’ node suddenly appeared, and all was good! Maybe it will work for you!

Auto-Complete not working in Eclipse

After upgrading from Linux Mint 13 to 17 (and Eclipse from Juno to Luna) I noticed that auto-complete (also called content assist) which is normally invoked using Ctrl+Space is not working anymore. After searching I found it is not actually caused by Eclipse, but instead the IBus (Keyboard) preferences eat Ctrl+Space so Eclipse never receives it! This is a very poor choice of global shortcut and it has been reported as a bug here. You can confirm Eclipse is not receiving it by going into Window->Preferences->General->Keys and attempting to enter Ctrl+Space for a key.

Until it is fixed, you can work-around it by right-clicking the keyboard icon in the system tray (next to the clock), choose ‘Preferences’ and select a different shortcut for ‘Next Input Method’.

Command history in Android Terminal

Here’s a tip if you are usingthe Terminal Emulator app by Jack Palevich in the Play Store:

To recall your previous command use VolumeUp + w (lower case) and VolumeUp + s (lower case) to move forward in the command history.

Because typing on a tablet soft keyboard sucks.

USB Driver for Nexus 5 on Windows 7

When I plugged in my Nexus 5 to my Windows 7 PC, it was not recognised, even after I used the Android SDK Manager to install the latest Google USB Driver. I finally worked out that there is a manual step you must take: Check the tooltip to find out where the USB driver was downloaded to (I found one under Program Files folder that was not installable – make sure you refer to the tooltip), and use Device Manager to update the driver, pointing to this folder. Then you can debug on your Nexus using ADB.

usb-driver

Git Bash Scripts

Using git as your source control, but have to use it on Windows? You may want to run some shell scripts like I did in git bash console (msysgit). I found that chmod does not actually work to add the executable bit to the file permission, but provided you add

#! /bin/bash

as the first line in your script file, you don’t even have to use chmod, Mingw32 automatically adds that bit in this case and you can execute immediately.

Source: msysgit on google groups

Setting LinearLayout background on activity launch

Just came across an issue where on one device (HTC Desire X) I was unable to set the background resource for the root LinearLayout of my activity’s view, even though it worked fine on multiple other devices. The code I was using:

setContentView(R.layout.background);
LinearLayout appBackground = (LinearLayout)findViewById(R.id.appBackground);
appBackground.setBackgroundResource(someResourceId);

The above code was called from onCreate(), and a call to invalidate() didn’t help. To fix it I had to post a delayed runnable to set the background a little later:

setContentView(R.layout.background);

new Handler().postDelayed(new Runnable() {
  @Override
  public void run() {
    LinearLayout appBackground = (LinearLayout)findViewById(R.id.appBackground);
    appBackground.setBackgroundResource(backgroundResourceId);
  }
}, 200);

Yes it sucks, but it works and the delay is not noticable. Variation between Android devices sucks :S

Android header preferences on small screen / phone

Short version: If your android preference headers are displaying on a small screen, but not opening the associated preference fragment when clicked, make sure you don’t have launchMode attribute set on your preferences activity in your AndroidManifest.xml file.

Long version: The concept of two-pane preferences of course applies to large screen (tablet) devices, where the left hand-side is a list of ‘headers’ and the right hand side is an associated preference fragment. Google’s built-in template for ‘SettingsActivity’ shows how this can be implemented such that when the activity is displayed on a small screen (e.g. phone) the preference headers are not displayed and instead all preferences are shown on the one screen, separated by categories. To do this they force you to use a deprecated API, which is pretty ugly. Additionally, this only makes sense when you don’t have many preferences. Once you have a large number of preferences, it may make sense to use headers on a small screen, which was the case for me, however it wasn’t working. The headers were displaying fine, but whenever I tapped one, nothing would happen, the onCreate() method of the associated fragment would not be called. By trial and error I finally found that I had

android:launchMode=”singleTask”

in my manifest file. As soon as I removed that attribute, preference headers worked on a small screen fine.

“No Permissions” when listing android devices

When plugging in a new Android device to your computer for debugging, you might see this when executing adb devices:

List of devices attached
???????????? no permissions
13716365315 device

This shows that 2 devices are attached, but only 1 of the two are working / recognised. To solve this you can try killing and restarting the adb server. To do this on linux, change to your android-sdk-linux/platform-tools directory in a terminal shell, then type:

sudo su
adb kill-server
adb start-server

Now try adb devices again and hopefully you see your device ok.

No mobile data access on Android phones

I just got a bueat new phone, the HTC Desire X, but one day two I suddenly had no internet access when on a mobile network (wifi was fine). The ‘Mobile Network’ setting was switch ON and toggling this switch didn’t do anything. I learned you have to check your APN (Access Point Name) settings by going into the Mobile network settings, then ‘Access Point Names’ and I saw that there was nothing listed there! Hit ‘Menu’ key and there’s an option to ‘Reset to defaults’. After I did this, my network operator’s settings appeared (Virgin Mobile Australia) and all was well!

Streaming media from Samba share to Android

Like many, I have a server/NAS that contains all my media (movies, music, photos, documents etc.), which is accessible via a Samba share to PCs in my house via LAN/wifi. XMBC works great to view all the media on-demand on the TV, however I was looking for a way to stream the media to an Android tablet (Samsung Galaxy Tab 10.1). And I found a REALLY simple, free solution:

  1. Install ES File Explorer (free) from the Android Market.
  2. Install RockPlayer Lite (free) from the Android Market.
  3. Open ES File Explorer and change view to LAN, then hit ‘New’ then ‘Server’ (from menu).
  4. Enter your server/NAS IP address, then a forward slash, then your share name, and any credentials if necessary.
  5. Hit OK, now you should be able to browse all the files on your Samba share with ease.

Now, when you tap on a movie file (avi/mpg/wmv etc.), you will get a prompt to choose which video player to use. Select RockPlayer Lite, and your movie will start playing within a few seconds. I’ve tested this for a variety of movie file types and sizes and RockPlayer Lite works really well, including skipping forwards and backwards through movies. For HD movies, expect to wait a little longer for the movie to buffer before it begins to play (e.g. > 10 seconds), once it gets going it seems pretty stable (no buffering). I’ve also tested this approach on an Android smartphone (LG P500 Optimus One, as well as the Samsung Galaxy S, both running Android 2.2) and it works just the same on the phone as the tablet). Awesome! And of course, you can also use this approach to play music and view photos from your server anywhere in range of your wifi signal 🙂

Can iPad do that!? :p