How to fix Nexus 4 Black Screen and not charging problem

This morning it happened: MY NEXUS 4 WAS DEAD ! BLACK SCREEN !
Pushing the power Button had no effect and when i tried to charge it there was no battery symbol.
I tried everything with success !

1. Remove the Nexus 4 from the charger.

2. Press and Hold Power + Vol Down for 20 seconds

3. Connect the Nexus 4 to the Charger AND ….

4. Black Screen Problem should be solved !

if not try again. If nothing helps and you had problems charging you Neuxs 4 before. Try another usb cable to charge you phone. Maybe you charging port is broken. If you have a friend with a Qi Wireless charging station give it a try.

Download and Install Android Studio 0.8.12

Two days ago the brand new Android Studio version 0.8.12 (download) was release. It brings a totally new Android Virtual Device Manager (AVD Manager). Its more easier to use and allows you to quickly deploy your App on a Emulated Device (better integration). Other changes are mainly for a better and smoother usability. If you want do have more details please visit the Android Studio 0.8.12 change log page.

 

0. Pre-Requirements

For absolute beginner please first check if you have java installed (at lease v1.6). To do that simply type: javac -version

javac -version

If this is not installed please go to the Oracle website and download the Java JDK.

 

1. Download Android Studio 0.8.12

Go to Android Tools Project Site to download the latest version of the Android Studio IDE. It is available for Windows, MacOS and Linux. As you can read in the NOTES the Android SDK is not included. So we also need to download that. Simply go the Android Developer Site and Download the Android  SDK for an existing IDE. I’ve made the experience that you can’t download the SDK using Chrome or IE. So I had to use Firefox. Really odd.

As Windows user you can download the recommended Installer version.

 

2. Install Android Studio 0.8.12 on Mac and the Android SDK (as standalone)

Installation is quite simple. On MacOS you simply have to extract the android-studio-ide-135.1503853-mac.zip and put the “Android Studio.app” into you Program folder (as usual).

If you would start it now this Warning will be popup: Your Android SDK is missing, out of date, or is missing templates.

Your Android SDK is missing, ut of date, or is missing templates

So first unzip the SDK zip, android-sdk_r23.0.2-macosx.zip. Next is finding a place where you want to store the SDK. I created a Android folder in my home-directoy and copied the android-sdk folder into it. So that the Path to my Android SDK is “/Users/your-username/Android/android-sdk-macosx/“. Please remember where ever u put it.

Android SDK folder structure

Android SDK folder structure

 

3. Configure the Android Studio for the Android SDK

Now we can start Android Studio. On the “Welcome to Android Studio”-Dialog we click “Configure” –> “Project Defaults” –> “Project Structure”. On the “Android SDK location” we click on the “…” Button and navigate to the location of the SDK. Than press “Ok”.

Setting the SDK Path in Android Studio

Setting the SDK Path in Android Studio

The Android SDK is now configured and can be used.  With the little blue arrow at the top left corner we can go pack to the start dialog.

 

4. Create a Android Project

We can now select “New Project…” and click next. The wizard is quite easy to understand. Simply fill in all fields and press Next.
Example:
Application Name: My First Android App
Company Domain: mycompany.com or myname.com
Project Location: /Users/your-username/Android/Workspace/MyFirstAndroidApp

The next Page is about the Android SDK that you want to use to compile (create) your app. It atm it usually suggests to take API 15 which is fine. There is also a explanation for the impact of the selected API version. It says:

Lower API levels target more devices, but have fewer features available. By targeting API 15 or later, you app will run on approximately 87,9% of the devices that are active on Google Play Store.

So, if you want to support Devices running Android 1.6 you have to pick API 4. But you can’t use features like the fancy ActionBar if you do so.

On the next Page they may ask you for some licence agreement and then download the SDK API Version in case it’s not already stored in your android-sdk folder.

Than, finally the wizard asks you with which “template activity” you want so start. For now se select “Blank Activity” and click next.
Template Activity

Now you can name your Activity (the class), the Layout (xml file), the Title (name displayed on the running app) and the menu res name (xml to define the menu). You can rename stuff here if you like. Click FINISH.

5. Android SDK Manager

Click on the Android Symbol with the blue little download box. If you want you can select more

android sdk manager

Android emulator: Failed to open the hax module

I had the Problem that i could not start the android emulator on my Macbook (Mac) using “Intel Atom x86”.

Problem:

emulator: Failed to open the hax module
hax is not working and emulator runs in emulation mode mac

Solution was downloading this fix.

https://software.intel.com/en-us/android/articles/intel-hardware-accelerated-execution-manager

Android ActionBar “Check” and “Cancel” Icon Images

I recently was looking for Images for my Android app and could not find files were i was sure that i’m allowed to used them. I this case i needed “check” or “done” icons and a “cancel” icon.
ic_done ic_canel

I made some myself. There are free to use. I included the src photoshop files (psd) and the png’s for all different sized (xxxhdpi, xxhdpi, xhdpi, hdpi and mdpi)

Download Icons (mirror)

EasyBox 802 als Vorschalt-Modem über LAN1 Internet (Tutorial)

Die Folgende Anletung erklärt Schritt-für-Schritt wie ihr eure EasyBox 802 als Vorschalt-Modem verwendet könnt, also mit einer bestehenden Internet Verbindung per LAN1 das Gerät als WLAN Router nutzen könnt. Diesen Fall hat man häufig bei KabelDeutschland.

Schritt 1:

Router resetten. Dazu drückt ihr 10 Sekunden lang mit einem Sspitzen Gegenstand in die Einlassung die mit RESET beschriftet ist.

Schritt 2:
Mit dem Router Verbinden. Verbindet euch mit dem Router per LAN Kabel.
Öffnet den Browser und verbindet euch auf Box indem hier ihr IP-Adresse eingebt.
In der Regel sollte diese wie folgt lauten: http://192.168.2.1/
Nehmt keine Einstellungen vor !

Schritt 3: Vorschalt-Modus (VDSL) aktivieren. Die EasyBox 802 besitzt selbst kein VDSL Modem, daher gibt es den Vorschalt-Modus zu verwenden und die EasyBox802 nur als WLAN Router zu verwenden. Dazu ruft ihr die “vdsl_enable.stm” Seite auf. Ist die IP eures Router 192.168.2.1 so lautet diese:
http://192.168.2.1/vdsl_enable.stm
Setzt den Haken bei “LAN Port 1 als Uplink für ein externes Modem benutzen”.

Vorschalt-Modem EasyBox 802

Vorschalt-Modem EasyBox 802

Schritt 4:
Wartet 3 minuten und Versucht euch dann wieder mit der Box zu verbinden. Sollte dies nicht gelingen startet die Box neu (nicht resetten – nur neustarten).

Schritt 5:
Wenn ihr mit der Box verbunden seid sollte ihr nach dem einloggen (User: root – Passwort: 123456) im ersten Dialog auf “Benutzerspezifische Installation” klicken. Im Folgedialog “Offener Modus”

Schritt 6:
Nun kommt ihr zu der Standard Startseite der Vodafon EasyBox 802 mit der besonderheit das bei Internet “Ethernet Uplink: Nicht verbunden” steht. Klickt im Menü auf “Daten” und dann “WAN”. Bei WAN 1 übernehmt ihr folgende Einstellungen:

Protokoll: “Routing”
IP-Adresse bleibt auf 0.0.0.0
DHCP Client: Haken setzen
802.1Q (1p/VLAN ID) Tagging auf 0

Schritt 7:
Mögliche Netzwerkkonflikte aus dem Weg räumen. Mein Router, welches die EasyBox gleich mit Internet versorgen soll, befindet sich ebenfalls auf der IP 192.168.2.1. Daher musste ich die IP Adresse der Easybox 802 ändern. Dazu klickt ihr im Menü auf “Startseite” und dann “LAN”. Ich habe die IP auf 192.168.3.1 gesetzt. Im Anschluss übernehmen und warten bis die Einstellungen übernommen wurden. Trennt nun kurz eure WLAN oder Kabelverbindung und verbindet euch wieder wenn die Box neugestartet ist. Die Box ist nun über die neue IP Adresse erreichbar.

Schritt 6:
EasyBox 802 an das LAN anschließen. Das Netzwerkkabel welches zuvor euren Rechner mit der Box verbunden hatte benötigt ihr nicht mehr. Verbindet nun euer Netzwerk mit dem EasyBox 802 und nutzt dafür den Uplink Port (also LAN1).  Voraussetzung ist das euer Netzwerk ein DHCP Server verwendet.

Schritt 5: 
Verbindet euch mit dem WLAN der EasyBox 802 und genießt.

 

How To: Set Bluez into BLE or LE only mode (IBeacon)

By default a bluetooth device driven by bluez will appear as a “BLE and ER/EDR” or “Both” device. If you want it to be an LE only device this is what you need to do:

btmgmt le on
btmgmt bredr off

Info: the btmgmt command is not in the set of tools that are installed by default. Also your kernel version must be at least least version 3.13

To install btmgmt (bluez) go the the folder with the source code and run:

./configure --prefix=/usr    \
        --sysconfdir=/etc    \
        --localstatedir=/var \
        --enable-tools       \
        --disable-test       \
        --disable-systemd

you may need to add:
--with-systemdsystemunitdir=/lib/systemd/system --with-systemduserunitdir=/usr/lib/systemd

Next:

make

and:

sudo /usr/bin/install -c tools/btmgmt /usr/bin/btmgmt

How to: Build you own Bluetooth Low Energy IBeacon for 10 $ DIY

IBeacons become more and more popular but most companys charge about 30$ for them. Thats way to much, so lets to it ourselves.
But first… the Shoppinglist:

HM-10 (http://imall.iteadstudio.com/im130614001.html) 6,50$
Battery Holder for Coincells (http://imall.iteadstudio.com/im120803016.html) 0,20$
Protoboard (http://imall.iteadstudio.com/im121207002.html) 0,60$
Steel Pins (http://imall.iteadstudio.com/im120706003.html) 1,50$
CR2025 CoinCell  1,00$

HM10 BLE Module

HM10 BLE Module

First we should have a look in the datasheet (HM10 are made by http://www.jnhuamao.cn/) and search for this graphic:

HM-10 Wiring

HM-10 Wiring

Important for us are actually only UART_TX, UART_RX, GND and 3.3V. If you want you can also use pin23 and pin24 to have leds on you beacon. But using the leds will cost energy.

Next we take the steel pins and bend them in a way that they match the indentations on the HM-10 board. Than we can start soldering.

HM-10 soldered to pins

I also soldered some pins on the right side of the HM-10 this give more stability and it won’t break so fast.
We also need Pins to connect them to a serial interface and flash new firmware or configure the module.

DIY IBeacon with HM-10

to be continued … 🙂

Fix: Bluez keeps crashing

I had the problem that my BlueZ was continuously crashing. Even when I was just using a few commands of for example hcitool or scanned for advertising BLE devices (as example). 

Set scan parameters failed: Input/output error.

I than checked dmesg to find out more:

Bluetooth: hci0 command tx timeout.

At the beginning i tried to shut it down and up again.

hciconfig hci0 down 
hciconfig hci0 up

or

service bluetooth restart
service dbus restart

And it worked – sometimes :-/ Even better was removing the Bluetooth Stick and plug it in again. But that was annoying. So i figured out how to reset a usb device from command line tool. First use lsusb to find the vendorId and use grep to search for it.

lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. 
Bus 001 Device 004: ID 0a5c:21e8 Broadcom Corp. 


cd /sys/bus/usb/devices/

grep -i -s -r 0a5c *
…
1-1.2/idVendor:0a5c
…

cd 1-1.2

echo 0 > authorized
echo 1 > authorized

So my usb device was in /sys/bus/usb/devices/1-1.2/. In the moment when you set the value in authorized to 0 the usb bluetooth device is not longer allowed to communicate with your computer (this is what I guess). And after setting it to 1 it is forced to re-init. Awesome. This is a solid solution.

 

Anyway I was looking for a solution that totally fixes the problem permanently. 
First I updated the kernel to the latest version. Since I was using an raspberry pi this can easily be done be using this commands:

cat /proc/version
sudo rpi-update
sudo reboot

Than i change the content of my /boot/cmdline.txt to:

dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline dwc_otg.microframe_schedule=1 dwc_otg.speed=1 rootwait

And after rebooting my problem was fixed. 🙂 Change to your cmdline.txt may cause problem with others USB devices. So to change it back later. Backup it first.

HowTo: Install bluez and dbus

I had a lot of trouble installing bluez-5.16 on my Raspberry Pis. But finally i made it and i wrote a little script. Which might be helpful for many of you.

Bluez is supporting the Bluetooth Low Energy (BLE) or Bluetooth Smart stack. So first thing i did was buying a Bluetooth LE USB Dongle on Amazon (DE / US).

Anyway here is the script. It’s pretty ugly written any maybe you should just copy and paste it line by line to install it on your machine otherwise i might miss some error messages that could occure. I’m using bluez-5.17 amd dbus-1.8.0.

 BE CAREFUL WITH SIMPLY COPYING THE COMMANDS, SOME CHARACTERS WILL BE WRONG e.g. the — of the .configure.

#!/bin/bash

if [ “$(id -u)” != “0” ]; then
echo “Sorry, but you have to be root.”
exit 1
fi
apt-get update
apt-get upgrade
apt-get install libusb-dev libdbus-1-dev libglib2.0-dev libudev-dev libical-dev libreadline-dev
echo “Creating bluez_temp folder”
mkdir bluez_temp
cd bluez_temp
echo “Download: bluez-5.17”
wget http://www.kernel.org/pub/linux/bluetooth/bluez-5.17.tar.xz
echo “Download: dbus-1.8.0”
wget http://dbus.freedesktop.org/releases/dbus/dbus-1.8.0.tar.gz
echo “uncompressing”
tar –xz -xvf bluez-5.17.tar.xz
tar xzf dbus-1.8.0.tar.gz
cd dbus-1.8.0
echo “install dbus-1.8.0”
./configure
make
make install
cd ../bluez-5.17
echo “install dbus-1.8.0”
./configure –disable-systemd –enable-library
make
make install
sudo apt-get install python-bluetooth python-requests
sudo hciconfig hci0 up

To avoid a problem that might occur we need to add a permission to the dbus bluetooth config.

sudo su –
cd /etc/dbus-1/system.d
nano bluetooth.conf

and add this

 

Than restart the service: service dbus restart.

How often does an IPhone with iOS7 turn on WiFi and send Probe Requests

To look up it’s current Position Smartphones continiously send out WLAN Request to use the Responses for Positioning. The Response includes the SSID of a Access Point close by. This Information can be used to look up in a database and find out the rough position (~15 meters).
This cost a bit of energy though no that much that it would have a big impact in use batterie. And it consumes even much less energy than GPS would.

Normally this lookup happens every 10sec, 30sec, 90sec.  But since the last iOS Update iOS7 it changed fundamentally the behavior of those Lookups on the IPhone.

Experiment with active IPhone:
(time difference to next probe request in sec)
3, 8, 4, 8, 21, 9

Experiment with sleeping IPhone on table:
(time difference to next probe request in sec)
479 (~8min after turn off the screen), … (15 minutes later stilll nothing !)

Experiment with sleeping IPhone in pocket:
still nothing

With iOS7 wifi seems to by totally switched off. Or at least it doesn’t send a single probe request.
Maybe it still monitors the WiFi traffic but i was not able to check this.