Get list from Website ( PHP , MySQL , HTTP request , XML )

by DemOlitioN » Fri, 10 Apr 2009 01:55:00 GMT


Sponsored Links
 m having a problem.

I am trying to build a software that communicates with a website.
simply, i would like to have a php webpage that when i click a button
it creates an alert on the phone.

I planned on doing that by using a mysql database to with the website
where the click from the webpage will update the database, then the
mobile phone will (at intervals) make a request to the webpage or
database to retrieve that info.

Here's what im thinking of using:
PHP
Mysql
Android OS
Windows Mobile OS

I found a tutorial from Apress called 'Apress Android Tutorials July
2008' and found an example that was about 90% similar to what i want
(with the source code) but when i try it i get errors and I cant find
a way to contact Apress(site is down etc)

The example was called Chapter 5: Loading a List from the Web. when i
use eclipse with the source, the error i get is "UIThreadUtilities
cannot be resolved". I noticed that when i excluded the rest of the
code and specify to import UIThreadUtilities it doesnt work.

I know this message is a bit long and it involves a lot but If anyone
can please help:

1. request i send them the source code from Apress to see if it works
on their eclipse. So I know how to fix it.

or

2. recommend an alternative way for me to pull info from a URL(or php
page) or a database.




Heres the code its supposed to pick a list of radio stations via xml
parsing from a web location:
I get errors where it says UiThreadutilities and other related places

======================================================================
package com.apress.radio;

import java.io.InputStream;
import java.util.List;
import java.util.Vector;

import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.impl.client.DefaultHttpClient;
import org.xml.sax.Attributes;
import org.xml.sax.InputSource;
import org.xml.sax.Locator;
import org.xml.sax.XMLReader;

import android.app.Activity;
import android.app.ListActivity;
import android.content.Context;
import android.graphics.Color;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.speech.recognition.Logger;
import android.util.Log;
import android.view.UIThreadUtilities;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnFocusChangeListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.TextView;



public class StationPicker extends ListActivity {

Vector<StationData> stationListVector = new Vector<StationData>();
SAXParser parser = null;
XMLReader reader = null;
XMLHandler handler = new XMLHandler();
ArrayAdapter<StationData> adapter = null;
Activity ctx = this;


class XMLHandler implements org.xml.sax.ContentHandler
{
StationData currentStation;
String lastName;

public void endDocument(){}
public void endPrefixMapping(String prefix){}
public void ignorableWhitespace(char[] ch, int start, int
length)
{}
public void processingInstruction(Strin



Get list from Website ( PHP , MySQL , HTTP request , XML )

by Mark Murphy » Fri, 10 Apr 2009 06:17:57 GMT


 


That tutorial is rather old from the standpoint of Android. Most
tutorials written before September 2008 will require some amount of
modification to work on current Android SDK editions.


That class was removed from the SDK, IIRC.


Use a more up-to-date resource!

There are many open source Android projects on code.google.com and
github.com. Many of these download data off of the Web. For example,
there projects in the apps-for-android project on Google Code that work
with Flickr's API.

There are several books on Android, at least some of which have their
source code available for download, and some of which cover HTTP
operations. For example, you can download the source code for my book
off of  http://commonsware.com/Android/. Other books and programming 
resources can be found on my knol:

 http://knol.google.com/k/mark-murphy/android-programming 

For HttpClient proper, there are examples out on their site:

 http://hc.apache.org 

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com  |  http://twitter.com/commonsguy 

Android App Developer Books:  http://commonsware.com/books.html 

--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Other Threads

1. If I call dismiss() from my Dialog's onCreate the dialog doesn't disappear

I have a dialog that I want to kill off if the android screen is
rotated.
In this case the onCreate of my dialog is called with a non-null
bundle arg.

I want to "send it away" at this point, and thought I'd just call
"dismiss()" from
onCreate. No go, the dialog still pops up.

Does anyone know how to properly kill the thing without having it
flash onto
the screen briefly and then vanish?

In my main Activity I'm managing the dialog by overriding
onCreateDialog and onPrepareDialog.

Thanks,

pawpaw17
--~--~---------~--~----~------------~-------~--~----~

2. why my textview dont show the edge of right

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="@+id/widget77"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android"
<TextView
android:id="@+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Date"
</TextView>
<TableRow
android:id="@+id/widget80"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
<TextView
android:id="@+id/content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
</TextView>
<TextView
android:id="@+id/num"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:gravity="right"
</TextView>
</TableRow>
<ScrollView
android:id="@+id/widget60"
android:layout_width="fill_parent"
android:layout_height="200px"
<TableRow
android:id="@+id/widget109"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
<TextView
android:id="@+id/stringcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
</TextView>
//i want to show it at the right,but it always shows next to the
textview
<TextView
android:id="@+id/stringnum"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
android:gravity="right"
</TextView>
</TableRow>
</ScrollView>
<TableRow
android:id="@+id/widget82"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
<Button
android:id="@+id/showdetails"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
</Button>
<Button
android:id="@+id/showcatogery"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
</Button>
</TableRow>
<TableRow
android:id="@+id/widget90"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
<Button
android:id="@+id/prev"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="quot;
</Button>
<Button
android:id="@+id/after"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="quot;
</Button>
</TableRow>
<TableRow
android:id="@+id/widget91"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
<Button
android:id="@+id/showreturn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="quot;
</Button>
</TableRow>
</LinearLayout>

--~--~---------~--~----~------------~-------~--~----~

3. Rendering of Android User Interface on different devices.

4. Help: Contact sorting by stroke for zh_TW LOCALE

5. Spinner focus

6. R.java Not foudn exception

7. How can I do this?