Friday, September 26, 2008

android




Android
Android documentation
Getting started with Android
Android FAQs
Installing the Android SDK - The API is Java
Developing and Debugging Android - You use Eclipse as the SDK
Hello world app with Android


package com.android.hello;

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

public class HelloAndroid extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView tv = new TextView(this);
tv.setText("Hello, Android");
setContentView(tv);
}
}



Android uses ALSA for audio
Android media API

Recording audio with Android:

Start recording:

recorder = new MediaRecorder();
ContentValues values = new ContentValues(3);

values.put(MediaStore.MediaColumns.TITLE, SOME_NAME_HERE);
values.put(MediaStore.MediaColumns.TIMESTAMP, System.currentTimeMillis());
values.put(MediaStore.MediaColumns.MIME_TYPE, recorder.getMimeContentType());

ContentResolver contentResolver = new ContentResolver();

Uri base = MediaStore.Audio.INTERNAL_CONTENT_URI;
Uri newUri = contentResolver.insert(base, values);

if (newUri == null) {
// need to handle exception here - we were not able to create a new
// content entry
}

String path = contentResolver.getDataFilePath(newUri);

// could use setPreviewDisplay() to display a preview to suitable View here

recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
recorder.setOutputFile(path);

recorder.prepare();
recorder.start();


Stop recording

recorder.stop();
recorder.release();


Location-based Service APIs


locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
Location location = locationManager.getCurrentLocation("gps");


How to Program Google Android