Archive for category Android

Android Fortune (Cookie/Teller) v0.2

Added support forĀ  mp3 playing (pause,resume when getting out of the fortune teller).

Launch you emulator with “-useaudio” then do this for instance:

adb push Benny\ Hill\ TV\ Theme.mp3 /system/media/audio/songs/fortune.mp3

Enjoy ;-) fortune2-v02.tgz

No Comments

Android Fortune (Cookie/Teller)

fortune.png

This is a basic fortune teller, loading a URL from the web and displaying a random fortune.

fortune-v01.tgz

No Comments

FileBrowser v0.4

filebrowser-v04.tgzfb-v04.png

Now can play .mid and .mp3 files.

No Comments

FileBrowser v0.3

fb-v03.pngfilebrowser-v03.tgz

Update, added Icons and Regular Expression matching of files. It takes a long time, due to Internet download of Icons.

No Comments

FileBrowser v0.2

Update now directories in bold and regular files normal font. Found a bug, when “cd forbidden_dir” cannot go back due to “cd forbidden_dir/..” cannot work have to fix this stupid thing. Added another class see attached archive. filebrowser.tgz

No Comments

Basic List

This is a basic List with menu and selector. TODO Add, switch to Help frame.

package fr.boucaron;

import java.util.ArrayList;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class MyAdapterList extends BaseAdapter {
protected ArrayList<String> mArrayList;
protected Context mContext;
//MINE
public void add(String t) { mArrayList.add(t); }
public void remove(int position) { mArrayList.remove(position); }
public String get(int position) { return mArrayList.get(position); }

//TO DEFINE
public int getCount() {
return mArrayList.size();
}

public Object getItem(int position) {
return position;
}

public long getItemId(int position) {
return position;
}

public MyAdapterList(Context c) {
mContext = c;
mArrayList = new ArrayList<String>();
}

public View getView(int position, View convertView, ViewGroup parent) {
TextView t = new TextView(mContext);
t.setText(mArrayList.get(position));
return t;

}
}
package fr.boucaron;

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

import android.app.ListActivity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.View;
import android.view.Menu.Item;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class ActivityMyViewGroup extends ListActivity {

MyAdapterList myList;
int currentPosition;

public void initMyList() {
myList.add(“Abbaye de Belloc”); myList.add(“Abbaye du Mont des Cats”);
myList.add(“Abertam”); myList.add(“Abondance”);
myList.add(“Ackawi”); myList.add(“Acorn”);
myList.add(“Adelost”); myList.add(“Affidelice au Chablis”);
myList.add(“Afuega’l Pitu”); myList.add(“Airag”);
myList.add(“Airedale”); myList.add(“Aisy Cendre”);
myList.add(“Allgauer Emmentaler”); myList.add(“Alverca”);
myList.add(“Ambert”); myList.add(“American Cheese”);
}

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
super.setTitle(“MyViewGroup”);
myList = new MyAdapterList(this);
this.initMyList();
// this.setListAdapter(new ArrayAdapter<String>(this,
// android.R.layout.simple_list_item_1, myList));
this.setListAdapter(myList);
}

public boolean onKeyDown(int keyCode, KeyEvent event)
{
this.currentPosition = this.getSelection();
if ( keyCode == KeyEvent.KEYCODE_DPAD_LEFT) {
super.setTitle(“LEFT”);
return true;
}
else if ( keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) {
super.setTitle(“RIGHT”);
super.setTitle(“Selected ” + myList.get(this.getSelection()));
return true;
}
else if ( keyCode == KeyEvent.KEYCODE_BACK) {
super.setTitle(“BACK”);
return true;
}
else if ( keyCode == KeyEvent.KEYCODE_CALL) {
super.setTitle(“CALL”);
return true;
}
return false;
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
boolean result = super.onCreateOptionsMenu(menu);
menu.add(0, 0, “Find associations”);
menu.add(0, 1, “Remove this”);
menu.add(0, 2, “Help”);
menu.add(0, 3, “Add”);
return result;
}

@Override
public boolean onOptionsItemSelected(Item item) {
switch (item.getId()) {
case 0: //Find associations
super.setTitle(“Menu: Find association” + this.currentPosition);
break;
case 1: //Remove this
super.setTitle(“Menu: Remove this” + this.currentPosition);
myList.remove(this.currentPosition);
myList.notifyChange();
break;
case 2: //Help
super.setTitle(“Menu: Help”);
break;
case 3: //Add
super.setTitle(“Menu: Add” + this.currentPosition);
break;
default:
super.setTitle(“Menu: ” + item.getId() + ” ” + item.getTitle());
}
return super.onOptionsItemSelected(item);
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id)
{
super.setTitle(“onListItemClick” + this.myList.get(position));
}

}

No Comments

Tonio’s code for creating db on android stuff

package marvin.pack;

import android.app.Activity;

public class marvin2 extends Activity
{
protected void onCreate(Bundle icicle)
{
super.onCreate(icicle);
//setContentView(new GLView(getApplication()));
setContentView(R.layout.main);
TextView tv = (TextView) findViewById(R.id.text);
try
{
SQLiteDatabase db = createDatabase(“test”, 1, MODE_PRIVATE, null);
db.execSQL(“CREATE TABLE IF NOT EXISTS table1 (champ1 INTEGER)”);
SQLiteCursor cursor = (SQLiteCursor) db.query(“SELECT * FROM sqlite_master”, null);

String test = “Structure :\n”;
for(int i = 0 ; i < cursor.getColumnNames().length ; ++i)
{
test += cursor.getColumnNames()[i] + ” ; “;
}
test += “\n”;
while(cursor.next())
{
for( int i = 0 ; i < cursor.getColumnNames().length ; ++i)
{
test += cursor.getString(i) + ” ; “;
}
test += “\n”;
}

tv.setText(test);

db.close();
}
catch(Exception e) {tv.setText(e.toString());}
}

protected void onResume()
{
super.onResume();
}

protected void onStop()
{
super.onStop();
}
}

No Comments