Tatome – dein Telefon sagt dir, wer anruft …

Screenshot_2013-08-13-14-34-04

Die Idee zu Tatome ist mir beim Joggen eingefallen. Ab und an kommt es vor, dass während ich laufe mich jemand anruft. Dann musste ich das entweder komplett ignorieren oder das Handy aus der Handytasche nehmen und drauf sehen, wer anruft. Macht sich blöd beim Joggen …

Ich brauchte also ein kleines Programm auf dem Handy, was mir direkt ins Ohr – ich laufe meist mit Kopfhörern – sagt, wer da gerade stört. So weiß ich wer anruft, kann bei Bedarf schnell reagieren und doch rangehen. Oder laufe eben weiter, ohne neugierig sein zu müssen.

Standardmäßig ist das Programm so eingestellt, dass man es nur mit eingesteckten Kopfhörern aktiv wird. So brauche ich vor dem Sport an nichts mehr zu denken. Einfach Kopfhörer anstecken, Musikauswählen, Sporttracker an und los geht’s.

Tatome ist kostenlos und ohne Werbung. Aber es gibt erweiterte Optionen, die erst nach einen einmaligen In-App Kauf verfügbar sind.

Diese erweiterten Optionen sind, Tatome auch ohne angeschlossene Kopfhörer den Anruf ansagen zu lassen und eigene Texte für die Sprachausgabe zu definieren.

Interesse? Hier gibt’s Tatome:

Get it on Google Play

Transfer extra data to new activity but you don’t get in the new activity?!

 

If you want to transfer some extra data to the called activity you have to use the extra data within a intent. You can do it in this way:

Intent intent = new Intent(this, Activity2.class);
intent.putExtra(ActivityCategoryEdit.IDKEY, items.get(position).getID());
startActivity(intent);

You just have to read the extra data within the onCreate function in called activity. Just like that:

id = getIntent().getIntExtra(IDKEY, -1);

That works as long the transfered value is a integer. But the type of the transfered ID is long in my case and if you try this way with a long value you just get the default value (-1) in the Activity2. This cost me some time to find out why. I have to use getLongExtra to get it work. A simple change was the solution … like always 😉

Here the code for the long value in Activity2. Activity1 don’t need to be changed.

id = getIntent().getLonExtra(IDKEY, -1);

Maybe this will help you.

Dynamic tables with Android – Part II

Deleting dynamically added rows was a bit tricky at the first. I found my solution with storing the rows in ArrayList so I can easily remove them from the table. Just look at the code:

private ArrayList<TableRow> rows;

rows = new ArrayList<TableRow>();

//When creating and adding the row to the table save it also to the ArrayList
rows.add(row);

//Clear the dynamically added rows whenever we need it
private void clearTable(){
	if (rows.size() > 0)	{
		for (int i = 0; i < rows.size(); i++) table.removeView(rows.get(i));
    }
    rows.clear();
}

Adding rows to a table is described in Part I

Dynamic tables with Android


I’m developing a android app for our field staff here at work. I needed some tables for data output. First of all we need a XML layout:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/textSample"
        android:layout_width="match_parent"
        android:layout_height="70dp"
        android:text=""
        android:gravity="center"
        android:textSize="20dp"
        android:textStyle="bold" />
    <TableLayout
        android:id="@+id/tableSample"
    	android:layout_width="match_parent"
   	android:layout_height="wrap_content"
    	android:stretchColumns="0" >
    	<TableRow
    	    android:id="@+id/tableHeader" >
        	<TextView
            		android:id="@+id/labelHeader1"
        		style="@style/TableHeader"
        		android:text="@string/label_header1" />
        	<TextView
            		android:id="@+id/labelHeader2"
        		style="@style/TableHeader"
        		android:text="@string/label_header2" />
        	<TextView
            		android:id="@+id/labelHeader3"
        		style="@style/TableHeader"
        		android:text="@string/label_header3" />
        	<TextView
            		android:id="@+id/labelHeader4"
        		style="@style/TableHeader"
        		android:text="@string/label_header4" />
        </TableRow>
    </TableLayout>
</LinearLayout>

Then we need a layout for the dynamically added tablerows:

<?xml version="1.0" encoding="utf-8"?>
<TableRow xmlns:android="http://schemas.android.com/apk/res/android">
    <TextView
    	android:id="@+id/textItem1"
        style="@style/TableItem"
        android:text="" />
    <TextView
      	android:id="@+id/textItem2"
        style="@style/TableItem"
        android:text="" />
    <TextView
       	android:id="@+id/textItem3"
        style="@style/TableItem"
        android:text="" />
    <TextView
       	android:id="@+id/textItem4"
        style="@style/TableItem"
        android:text="" />
</TableRow>

I placed the styles in the values/style.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">

    <style name="TableHeader">
		<item name="android:layout_width">wrap_content</item>
		<item name="android:layout_height">30dp</item>
		<item name="android:layout_margin">1dp</item>
		<item name="android:gravity">center_vertical</item>
		<item name="android:padding">3dp</item>
		<item name="android:textSize">14dp</item>
		<item name="android:textStyle">bold</item>
		<item name="android:textColor">@color/default_table_header_color</item>
		<item name="android:background">@color/default_table_header_background</item>
    </style>

    <style name="TableItem">
		<item name="android:layout_width">wrap_content</item>
		<item name="android:layout_height">25dp</item>
		<item name="android:layout_margin">1dp</item>
		<item name="android:gravity">right|center_vertical</item>
		<item name="android:padding">3dp</item>
		<item name="android:textSize">14dp</item>
		<item name="android:textColor">@color/default_table_item_color</item>
		<item name="android:background">@color/default_table_item_background</item>
    </style>

</resources>

We can put these all together with some java code:

TableLayout table = (TableLayout)getActivity().findViewById(R.id.tableSample);
while (some_data_still_come_in){
	TableRow row = (TableRow)LayoutInflater.from(this).inflate(R.layout.tablerow, null);
	((TextView)row.findViewById(R.id.textItem1)).setText("some text");
	((TextView)row.findViewById(R.id.textItem2)).setText("some text");
	((TextView)row.findViewById(R.id.textItem3)).setText("some text");
	((TextView)row.findViewById(R.id.textItem4)).setText("some text");
	table.addView(row);
	get_next_data();
}
table.requestLayout();

That’s all. Works fine and you get also a table feeling with this style.

Android Camera.autoFocus() failed

eclipseWhile coding a camera test program I run into the following problem… Camera.autoFocus(autoFocusCallback) failed the whole time with the error message „autoFocus failed“. The stacktrace contains:

java.lang.RuntimeException: autoFocus failed
at android.hardware.Camera.native_autoFocus

The internet wasn’t a real help on this topic. So I had to dig deeper on my own.
It was a bit tricky to find the error since I used a filter on my application in the logcat output. So I saw only the „autoFocus failed“ message. When I switched to „All messages“ I saw the camera is complaining that there is no active preview. Huh? But I saw the camera preview on the phone. Yeah, but this preview was created some milliseconds later than the first autoFocus request.

I use the SurfaceHolder.Callback -> surfaceCreated now to know when the surfaceHolder is created. After this I can start the AutoFocus.

Everything runs fine now 🙂