sabato 29 maggio 2010

Problem with HTC Desire and ADB driver? The solution is here.

If you try to connect your HTC Desire to your PC via USB having already installed the ADB driver for Android SDK, you will see that the driver is not working.

To fix the problem you need to install the USB driver coming with the HTC Sync (you can download here).

Thanks to James Giang for the tip.

martedì 25 maggio 2010

Generate a tone with Android

It is pretty easy play a simple tone (a beep) using Android. Two lines of code are enough:

ToneGenerator toneGen = new ToneGenerator(AudioManager.STREAM_SYSTEM, 50);
toneGen.startTone(ToneGenerator.TONE_PROP_BEEP);

Android: when the debug certificate expires

Today morning, big surprise! Trying to build my Android application I get this error:
"Debug Certificate expired on....."
What a f..k? And now? What I'm supposed to do?

No worries....going to the default storage location for AVDs which is in 

- ~/.android/avd on OS X and Linux, 
- in C:Documents and Settings\.android on Windows XP, 
- in C:Users\.android on Windows Vista 

you can delete the file debug.keystore and the next build of the projects will generate again a new valid 
debug certificate

giovedì 4 febbraio 2010

Android: Get events when an edit text content changes

This is a problem not very well documented by Google but it is a common task the developers have to do often.

The solution is use a TextWatcher object that will receive event when the text in the EditText changes:

// Watcher to chage char counter when sms text changes
TextWatcher textWatcher = new TextWatcher() {
    @Override
    public void onTextChanged ( CharSequence arg0, int arg1, int arg2, int arg3 ) {
    }

    @Override public void beforeTextChanged ( CharSequence arg0, int arg1, int arg2,  int arg3 ) {
    }

    @Override
    public void afterTextChanged ( Editable arg0 ) {
         updateCharCounter(); }
    };

m_smsTextField.addTextChangedListener(textWatcher);

domenica 31 gennaio 2010

Feyenoord - Ajax 1-1

Pantelic score in the first half for Ajax. Second half, Wijnaldum equalizes take advantage of an error of Emmanuelson, left back of Ajax.

Good chances for Feyenoord with Tomasson and Makaay.

Interesting young players in the Feyenoord line: Wijnaldum, Fer and the 17-years-old defender De Vrij.

lunedì 11 gennaio 2010

Access android database from the shell

It is very important knowing what we save in the database of our application. To check easily the stored data you can access the database following these steps:

  1. Launch the emulator

  2. Launch the Windows command prompt and go under the "Tools" directory in the android sdk folder

  3. Type "adb shell"

  4. Type "cd data/data"

  5. You find the list of all applications. Enter in your application folder (for example "mypackage.myapp")

  6. Type "cd databases". You find all the databases. 

  7. Launch "sqlite3 <name_of_database>

Type ".help" to have all the instructions.
With the command ".tables" you can list all the database's tables.

Now you can write your query: select * from <name_of_table>.

lunedì 16 novembre 2009