public void Fetch_Data(){
line = "";
try {
// Perform action on click
//Log.w("Fetchhhhhhhhhhhhh","You are going to fetch tip data");
String tempStr = "";
// Initiate the url connection
URL url = new URL(The_URL);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
// Get the response
BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
while ( (tempStr= rd.readLine()) != null) {
line = line + tempStr;
}
rd = null;
conn.disconnect();
}
catch (Exception e) {
Log.w("===========",e);
}
}
Thursday, November 18, 2010
Fetch data from html
How to use Spinner
private ListGame_Mode_List for (int i=0;i < Game_Mode.length ;i++) { // Populate the Game_Mode List Game_Mode_List.add(Game_Mode[i]); } // Put the Game_Mode_List to an Addapter and set addapter tpye ArrayAdapter Game_Mode_Addapter = new ArrayAdapter ( this, android.R.layout.simple_spinner_dropdown_item, Game_Mode_List); Game_Mode_Addapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item ); // Create Spinner and attach the addapter to it. Spinner Game_Mode_Spinner = new Spinner(this); Game_Mode_Spinner.setAdapter(Game_Mode_Addapter); // The listener will listen the change. arg2 is the item selected Game_Mode_Spinner.setOnItemSelectedListener( new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView arg0, View arg1, int arg2, long arg3) { myGameMode = String.valueOf(arg2); } @Override public void onNothingSelected(AdapterView arg0) { myGameMode = "1"; } } );
Tuesday, November 16, 2010
Program Android on Mac
According to some websites, in order to develop android device on a Mac, all you need to do is to add the adb tool path to your .bash_profile. There is a script that do that for you. adb for Mac
In addition to that, it seems the cable also play an important role. The cable comes with MID does not work. Only the cable comes with the LG ally can work with Eclipse.
http://northmendo.com/downloads/Install_adb.dmg
In addition to that, it seems the cable also play an important role. The cable comes with MID does not work. Only the cable comes with the LG ally can work with Eclipse.
Wednesday, November 10, 2010
Send data to php
A php can read "POST" data. The following code can be used.
public void Fetch_Html() {
try {
String Data_username = URLEncoder.encode("username", "UTF-8") + "=" + URLEncoder.encode("Test username", "UTF-8");
String Data_email = URLEncoder.encode("email", "UTF-8") + "=" + URLEncoder.encode("Test Email", "UTF-8");
String Data_tip = URLEncoder.encode("tip", "UTF-8") + "=" + URLEncoder.encode("This tip", "UTF-8");
String Quest_Data = Data_username + "&" + Data_email + "&" + Data_tip;
The_URL = "http://ad-mountain.com/tipSubmit.php";
// Initiate the url connection
URL url = new URL(The_URL);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setDoInput(true);
conn.setDoOutput(true);
conn.setUseCaches(false);
conn.setRequestMethod("POST");
conn.setRequestProperty("Connection", "Keep-Alive");
conn.setRequestProperty("Charset", "UTF-8");
conn.setRequestProperty("Content-Type","application/x-www-form-urlencoded" );
conn.setRequestProperty("Content-Length", "" + Integer.toString(Quest_Data.getBytes().length));
conn.connect();
DataOutputStream ds = new DataOutputStream(conn.getOutputStream());
ds.writeBytes(Quest_Data);
ds.flush();
Log.w("=========", Quest_Data);
conn.disconnect();
ds.close();
}
catch (Exception e) {}
}
Sunday, November 7, 2010
Good Android Resources
http://ophonesdn.com/forum/archiver/fid-5.html
and
http://ophonesdn.com/forum/index.jsp
and
http://ophonesdn.com/forum/index.jsp
Friday, November 5, 2010
Make Android connection
Update: Actually, both of the following code would work on my S7 and Ally. The headset I tried has only one profile implemented. That's the reason it can not be found by S7.
The following code is suggested.
mmSocket = device.createRfcommSocketToServiceRecord(MY_UUID); mmSocket.connect();
The following code is suggested.
private static String address = "00:19:7F:1F:20:DF";
private BluetoothSocket btSocket = null;
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address);
Method m = null;
m = device.getClass().getMethod("createRfcommSocket", new Class[]{int.class});
btSocket = (BluetoothSocket)m.invoke(device, Integer.valueOf(1));
btSocket.connect();
Subscribe to:
Posts (Atom)