Browsed by
Category: Android

Android: issue with updating apps

Android: issue with updating apps

When you have an Android smartphone and get an error with code ‘RPC:S-5:AEC-0’ when updating your Apps, carry out the following steps to get it working again:

  1. Goto Settings > Apps > All > Google Play Store and press ‘Clear data’ and ‘Stop now’
  2. Goto Settings > Google (in the Account section) en select your e-mail adres. Choose ‘Remove Account’ from the menu.
  3. Still in Settings, add a Google account, choose existing and enter your e-mail address and password.

Now you should be able to update your Apps as usual.

Remark: On my Google Nexus device with Android version 4.1.2,  I got this error after clearing the data of the ‘Google Service Framework’.

Galaxy Nexus Factory Reset

Galaxy Nexus Factory Reset

If you are ever in the situation that your Galaxy Nexus gets in a reboot loop, then you probably need to perform a factory reset.

These are the steps to do a factory reset:

  1. Remove the battery and put it back in
  2. Hold down the ‘volume up’ + ‘volume down’ + ‘power button’ at the same time
  3. In the menu select ‘Recovery mode’
  4. When you see an Android with an exclamation mark, hold down the ‘volume up’ + ‘power button’ at the same time
  5. In the menu select ‘wipe data/factory reset’
  6. Confirm by selecting ‘Yes’

The system will now completely erase your phone. So also the contents of the SD card will be erased.

After this select the reboot option and you can start setting up your phone.

After connecting to your (WiFi) network and logging in with your Google account the phone will start downloading all the Apps you had installed. Apps installed by using a .apk will not be installed automatically, so you will have to install them manually.

Tip: Setup your phone to automatically upload your photos and videos by using Apps like Google+ or DropBox

How to install Apps on the SD card with Android 2.2 (Froyo) by default

How to install Apps on the SD card with Android 2.2 (Froyo) by default

Also constantly have the problem after installing a new app on your device that you get a warning that the memory is almost full and that for example you don’t receive any new e-mails anymore?

When you own a device with at least Android 2.2 (Froyo), here’s a road map to try to solve the problem. The idea is to setup the device in such a way that by default all Apps are being installed on the SD card instead of the internal memory.

Perform the following steps so your device will install Apps on the SD card instead of internal memory:

  1. Goto Settings -> Applications -> Development and tick the checkbox for ‘USB-debugging‘.
  2. Goto www.oracle.com/technetwork/java/javase/downloads/ and download and install the Java SE JDK.
  3. Goto http://developer.android.com/sdk/ and download and install the Android SDK. Make sure that you select ‘USB Driver package’ during installation.
  4. Connect the device with a USB-cable to your PC. The operating system will now install the needed driver.
    Remark: only connect the cable and do not mount the device’s SD card to the PC.
  5. Open a command-prompt and goto the directory [android-sdk-dir]\platform-tools.
    Open command-prompt:  press Windows-key + R, type cmd and press Enter.
  6. Execute the following command to check if the connect device is recognized: adb devices.
    You should see some like this:
  7. Execute the following command: adb shell pm setInstallLocation 2. From now on the Apps get installed on the SD card by default.
  8. Untick the checkbox for ‘USB-debugging’ (see step 1)

Remarks:

  • If you want the Apps being installed in internal memory by default again, just execute the following command: adb shell pm setInstallLocation 0.
  • Keep in mind that not all Apps will run fine when they are installed in SD card. If an App also has Widgets, they probably will not work. Also Apps that install a service to regularly gets data will not work when installed on SD card.
Android – Customizing list view item layout

Android – Customizing list view item layout

In a previous article I described how to use a ListView to display data. In the example the data was shows using a string without any formatting. This article will show you how to change the code so the data will be shown in a better looking way. The data will be formatted by using a custom ArrayAdapter which will use a custom item layout.

Let’s start with the basics: the main.xml and the used data class.

main.xml:

[xml highlight=”16,17-20″]

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:id="@+id/header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical|center_horizontal"
android:textSize="20sp"
android:textColor="#FF0000"
android:text="ListView using standard ArrayAdapter and simple list layout"
/>
<ListView
android:id="@+id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>

[/xml]

The following code shows the data class which will hold the temperature data.

TemperatureData.java:

[java highlight=”14,15-37″]

package nl.jestersoft.listviewtryout;

import android.text.format.Time;

public class TemperatureData
{
// The data
String SensorName;
double CurrentTemperature;
double MinimumTemperature;
double MaximumTemperature;
String TimeStamp;

public String GetSensorName()
{
return SensorName;
}

public double GetCurrentTemperature()
{
return CurrentTemperature;
}

public double GetMinimumTemperature()
{
return MinimumTemperature;
}

public double GetMaximumTemperature()
{
return MaximumTemperature;
}

public String GetTimeStamp()
{
return TimeStamp;
}

public TemperatureData(String sensorName, double currentTemperature, double minimumTemperature, double maximumTemperature, String timeStamp )
{
SensorName = sensorName;
CurrentTemperature = currentTemperature;
MinimumTemperature = minimumTemperature;
MaximumTemperature = maximumTemperature;
TimeStamp = timeStamp;
}

@Override
public String toString()
{
String item;

// Just out out the data as a string
item = SensorName + ": " + CurrentTemperature + ", " + MinimumTemperature + ", " + MaximumTemperature + " (" + TimeStamp + ")";

return item;
}
}
[/java]

The data class has been extended with public methods so we can access the internal data fields. Below the adjusted main code is shown.

ListViewTryout.java:

[java highlight=”25,26,27″]
package nl.jestersoft.listviewtryout;

import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.os.Bundle;
import android.widget.*;

public class ListViewTryout extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

// Add some dummy data to the list
ArrayList<TemperatureData> tempData = GetDummyData();

// Get list to view data in
ListView list = (ListView)findViewById(R.id.list);

// Show data in the list
int layoutID = R.layout.listitem;
TemperatureAdapter tempAdapter = new TemperatureAdapter(this, layoutID, tempData);
list.setAdapter(tempAdapter);
}

public ArrayList<TemperatureData> GetDummyData()
{
ArrayList<TemperatureData> dummyData = new ArrayList<TemperatureData>();

TemperatureData data1 = new TemperatureData("Balcony", 18.0, 16.0, 20.0, "30-07-2011 13:14");
dummyData.add(data1);

TemperatureData data2 = new TemperatureData("Living room", 24.0, 20.0, 25.0, "30-07-2011 13:14");
dummyData.add(data2);

TemperatureData data3 = new TemperatureData("Bath room", 18.0, 21.0, 27.0, "30-07-2011 13:15");
dummyData.add(data3);

return dummyData;
}
[/java]

In this version of the main code we are not using the standard ArrayAdapter but a custom adapter (TemperatureAdapter). The adapter is now using a custom layout (R.layout.listitem) instead of the simple list item layout. Below the code for the custom adapter and list item layout is shown.

listitem.xml

[xml]

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>

<!– Column 1 –>
<TextView
android:id="@+id/currentTemp"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:gravity="center_vertical|center_horizontal"
android:layout_weight="1"
android:textStyle="bold"
android:textSize="28sp"
android:text="18"/>

<!– Column 2 –>
<TableLayout
android:layout_height="fill_parent"
android:layout_width="wrap_content"
android:layout_weight="1">
<TableRow>
<TextView
android:id="@+id/sensorDescr"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:textSize="16sp"
android:text="Balkon"/>
</TableRow>
<TableRow>
<TextView
android:id="@+id/timestamp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textSize="8sp"
android:text="30-07-2011 13:14"/>
</TableRow>
</TableLayout>

<!– Column 3 –>
<TableLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right">
<TableRow>
<TextView
android:id="@+id/maxLabel"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="bottom"
android:textSize="8sp"
android:text="max"/>
<TextView
android:id="@+id/maxTemp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:textSize="14sp"
android:layout_margin="1dip"
android:textStyle="bold"
android:text="20"/>
</TableRow>
<TableRow>
<TextView
android:id="@+id/minLabel"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="bottom"
android:textSize="8sp"
android:text="min"/>
<TextView
android:layout_height="wrap_content"
android:text="16"
android:textSize="14sp"
android:layout_width="fill_parent"
android:layout_margin="1dip"
android:textStyle="bold"
android:id="@+id/minTemp"></TextView>
</TableRow>
</TableLayout>
</LinearLayout>
[/xml]

You can create a layout just the way you want it. The custom adapter will ensure that the data will be displayed in the layout.

TemperatureAdapter.java

[java highlight=”34,35,38,62″]
package nl.jestersoft.listviewtryout;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.view.InflateException;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

public class TemperatureAdapter extends ArrayAdapter<TemperatureData>
{
private ArrayList<TemperatureData> items;
private Context context;

public TemperatureAdapter(Context context, int resource, ArrayList<TemperatureData> items)
{
super(context, resource, items);
this.items = items;
this.context = context;
}

@Override
public View getView(int position, View convertView, ViewGroup parent)
{
View temperatureView = convertView;

if ( temperatureView == null)
{
LayoutInflater inflator = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
temperatureView = inflator.inflate(R.layout.listitem, null);
}

TemperatureData item = this.items.get(position);

String sensorName = item.GetSensorName();
double currentTemperature = item.GetCurrentTemperature();
double minimumTemperature = item.GetMinimumTemperature();
double maximumTemperature = item.GetMaximumTemperature();
String timeStamp = item.GetTimeStamp();

TextView tvCurrentTemp = (TextView)temperatureView.findViewById(R.id.currentTemp);

TextView tvSensorDescr = (TextView)temperatureView.findViewById(R.id.sensorDescr);
TextView tvTimestamp = (TextView)temperatureView.findViewById(R.id.timestamp);
TextView tvMinTemp = (TextView)temperatureView.findViewById(R.id.minTemp);
TextView tvMaxTemp = (TextView)temperatureView.findViewById(R.id.maxTemp);

tvCurrentTemp.setText(String.valueOf(currentTemperature));
tvSensorDescr.setText(sensorName);
tvTimestamp.setText(timeStamp);

String min = String.valueOf(minimumTemperature);
tvMinTemp.setText(min);
String max = String.valueOf(maximumTemperature);
tvMaxTemp.setText(max);

return temperatureView;
}
}
[/java]

The most important code in this class is where an inflator is created and used to load the custom list item layout.

When you run the code you will see the following result.

Android – Using a list view to show data using the standard array adapter

Android – Using a list view to show data using the standard array adapter

In this article I will describe how to use a ListView to display data using the standard ArrayAdapter. The adapter will receive temperature data and will show it as a simple string in the list. For the data we create our own data class (TemperatureData).

Ok, let’s start with creating the main layout. In this layout we have a TextView which holds a header text and a ListView which will hold the temperature data.

main.xml:
[xml highlight=”16,17-20″]

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:id="@+id/header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical|center_horizontal"
android:textSize="20sp"
android:textColor="#FF0000"
android:text="ListView using standard ArrayAdapter and simple list layout"
/>
<ListView
android:id="@+id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>

[/xml]

The following code shows the data class which will hold the temperature data. Important in this code is the implementation of the toString() method. Without this method the ArrayAdapter cannot display the list items.

TemperatureData.java:
[java highlight=”23,24-32″]

package nl.jestersoft.listviewtryout;

import android.text.format.Time;

public class TemperatureData
{
// The data
String SensorName;
double CurrentTemperature;
double MinimumTemperature;
double MaximumTemperature;
String TimeStamp;

public TemperatureData(String sensorName, double currentTemperature, double minimumTemperature, double maximumTemperature, String timeStamp )
{
SensorName = sensorName;
CurrentTemperature = currentTemperature;
MinimumTemperature = minimumTemperature;
MaximumTemperature = maximumTemperature;
TimeStamp = timeStamp;
}

@Override
public String toString()
{
String item;

// Just out out the data as a string
item = SensorName + ": " + CurrentTemperature + ", " + MinimumTemperature + ", " + MaximumTemperature + " (" + TimeStamp + ")";

return item;
}
}
[/java]

Now we have the main screen and the data definition, let’s take a look at the main code.

ListViewTryout.java:

[java highlight=”25,26,27″]
package nl.jestersoft.listviewtryout;

import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.os.Bundle;
import android.widget.*;

public class ListViewTryout extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

// Add some dummy data to the list
ArrayList<TemperatureData> tempData = GetDummyData();             

// Get list to view data in
ListView list = (ListView)findViewById(R.id.list);

// Show data in the list
int layoutID = android.R.layout.simple_list_item_1;
ArrayAdapter tempAdapter = new ArrayAdapter<TemperatureData>(this, layoutID, tempData);      
list.setAdapter(tempAdapter);
}

public ArrayList<TemperatureData> GetDummyData()
{
ArrayList<TemperatureData> dummyData = new ArrayList<TemperatureData>();

TemperatureData data1 = new TemperatureData("Balcony", 18.0, 16.0, 20.0, "30-07-2011 13:14");
dummyData.add(data1);

TemperatureData data2 = new TemperatureData("Living room", 24.0, 20.0, 25.0, "30-07-2011 13:14");
dummyData.add(data2);

TemperatureData data3 = new TemperatureData("Bath room", 18.0, 21.0, 27.0, "30-07-2011 13:15");
dummyData.add(data3);

return dummyData;
}

}
[/java]

Note that the code uses the ‘android.R.layout.simple_list_item_1’ layout for displaying the items.

When you run the code you will see the following result.

Android4ever

Android4ever

Naar aanleiding van het bericht van een collega (Apple fan) dat hij redacteur is geworden bij www.apple4ever.nl (Armin gefeleciteerd!), was ik als Android fan benieuwd of de domeinnaam www.android4ever.nl nog vrij zou zijn. En deze bleek nog vrij te zijn en dus heb ik deze maar laten registreren. Er zit (nog) geen aparte site achter, maar dat gaat misschien nog wel een keer gebeuren. Voorlopig verwijst het domein naar deze site.

Armin, mocht je toch nog een keer van je geloof vallen, dan ben je hier als redacteur van harte welkom 😉

Hoe installeer ik apps standaard op de SD kaart met Android 2.2 (Froyo)

Hoe installeer ik apps standaard op de SD kaart met Android 2.2 (Froyo)

Ook constant het probleem dat na het installeren van een nieuwe App de melding komt dat het geheugen vol is en dat daardoor bijvoorbeeld je e-mail niet meer binnenkomt op je Android telefoon?

Indien je in het bezit bent van minimaal Android 2.2 (Froyo), dan is hier een stappenplan om het probleem op te lossen. Het idee is om je telefoon zo in te stellen dat Apps standaard op de SD kaart worden geinstalleerd i.p.v. het interne geheugen.

Voer de volgende stappen uit om de telefoon de Apps standaard op de SD kaart te laten installeren:

  1. Ga naar Instellingen -> Applicaties -> Ontwikkeling en zet een vinkje bij ‘USB-foutopsporing
  2. Ga nu naar http://developer.android.com/sdk/ en download de Android SDK. Zorg ervoor dat ‘Usb Driver package’ wordt geselecteerd tijdens de installatie.
  3. Sluit de telefoon nu aan met de USB-kabel. Het besturingssysteem zal nu de benodigde driver installeren.
    Opmerking: alleen de kabel aanlsuiten en er niet voor kiezen om de telefoon te koppelen als schijfstation.
  4. Open een command-prompt and ga naar de directory [android-sdk-dir]\platform-tools.
  5. Voer het volgende command uit om na te gaan of de telefoon goed wordt herkend: adb devices.
    Je krijgt nu het serienummer van de telefoon te zien. Het nummer begint met een ‘H’.
  6. Voer nu het volgende commando uit: adb shell pm setInstallLocation 2. Vanaf nu worden de Apps standaard op de SD kaart geinstalleerd.
  7. Zet het vinkje bij ‘USB-foutopsporing’ (zie stap 1) weer uit.

Opmerkingen:

  • Wil je weer standaard de Apps op het interne geheugen geinstalleerd hebben, voer dan het volgende commando uit: adb shell pm setInstallLocation 0.
  • Houdt er rekening mee dat niet alle Apps goed draaien indien ze op de SD kaart zijn geinstalleerd. Indien je bijvoorbeeld widgets van een App gebruikt, is er een kans dat deze niet werken. Ook Apps die zichzelf als service installeren om bijvoorbeeld op gezette tijden een hun data op te halen kunnen wel eens niet meer werken indien ze op de SD kaart zijn geinstalleerd.

Applicaties die het niet (goed) doen indien geinstalleerd op SD kaart:

  • Dolphin Browser HD: Internetten niet meer mogelijk.
  • TweetDeck: Updates komen niet meer (automatisch) binnen