Back button how to get rid of Activity stack without finishing

I have problem with back button on phone – I have back button in application which need to go to history, but same thing shouldn’t do phone’s hardware button. This solves my issue: http://stackoverflow.com/questions/2354336/android-pressing-back-button-should-exit-the-app

Slides which are really helpful about backstack: http://www.slideshare.net/RanNachmany/manipulating-android-tasks-and-back-stack

SimpleAdapter and Spanned from Html.fromHtml

In TextView which is part of ListView and SimpleAdapter the HTML tags are stripped, the solution is to add ViewBinder:

adapter.setViewBinder(new SimpleAdapter.ViewBinder() {
	public boolean setViewValue(View view, Object data, String textRepresentation) {
		if (data instanceof Spanned && view instanceof TextView) {
			((TextView) view).setText((Spanned) data);
		} else {
			((TextView) view).setText(String.valueOf(data));
		}
		return true;
		}
	}
);

More links

ArrayAdapter suitable for ImageView: http://android-er.blogspot.com/2010/06/custom-arrayadapter-with-with-different.html

Links of today

Transparent background of ListView after scroll: http://stackoverflow.com/questions/2833057/background-listview-becomes-black-when-scrolling

Useful links of today

Push Notifications for Android 2.2+: http://developer.android.com/guide/google/gcm/gs.html
Emulator Google Map error when no API is downloaded for VMD: http://stackoverflow.com/questions/1113088/install-failed-missing-shared-library-error-in-android
Sample code to draw route between two POIs: http://stackoverflow.com/questions/4408671/android-draw-route-on-a-mapview-with-twoo-poi-s
Example of reading GPS location (with listener): http://android-er.blogspot.com/2009/11/read-gps-location-locationmanager.html
Smooth polylines from Maps API: http://stackoverflow.com/questions/2964982/android-get-and-parse-google-directions

Simple QR code checking

This is scanning through the Intent – you need zxing library from http://code.google.com/p/zxing/ and Barcode Scanner from Market installed. After clicking button you are redirected to Barcode Scanner, which returns scanning result to Activity.

package com.example;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import com.google.zxing.integration.android.IntentIntegrator;
import com.google.zxing.integration.android.IntentResult;

public class QRCodeTestActivity extends Activity
{
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        Button qrButton = (Button) findViewById(R.id.qr_button);
        View.OnClickListener l;
        qrButton.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                IntentIntegrator integrator = new IntentIntegrator(QRCodeTestActivity.this);
                integrator.initiateScan();
            }
        });
    }

    public void onActivityResult(int requestCode, int resultCode, Intent intent) {
        IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);
        if (scanResult != null) {
            Toast.makeText(getApplicationContext(), "resultCode: " + resultCode + " -> " + scanResult.getContents() + " " + scanResult.getFormatName(), Toast.LENGTH_LONG).show();
        }
    }
}

Android free ebooks

There are already a lot of free ebooks which allow to start learning Android:

Learning Android
Android Application Development from A to Z
android design guidelines

Game engines

I was looking for the game engines for a 2D games in Android, and some Live Wallpaper helpers and I found a list of engines here:

http://stackoverflow.com/questions/5206089/game-engine-for-android

For now I have tested two of them: libgdx and AndEngine. AndEngine is pretty cool but I’m not sure what will happen to it when the main developer left it for Zynga. Yes, I see that he is still commiting, so I hope he will still work on this OS engine.

Live Wallpaper extension is also really cool.

Setup

public class TestHighlight {

	public void highlight() {
		System.out.println("Highlighted");
	}

}

	

Copyright © All Rights Reserved · Green Hope Theme by Sivan & schiy · Proudly powered by WordPress