Hi,

I am new in android as well as java programming. I need to develop an
application which will be able to get the information from a webpage
(php page) and use the information in the android app. I write a
simple android app but it doesnt work. Can anyone help me with this?
or give me some guidance?

php part is just echo a string "This is my string";

android part:
public class HelloAndroid extends Activity {
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
                String a;
                a = callWebPage(
                                
"http://www.uploadhub.com/mobile9/gallery/gallery_android/";,
                                "?str=helloWorld");
                super.onCreate(savedInstanceState);
                TextView tv = new TextView(this);
                tv.setText(a);
                setContentView(tv);
        }

        public String callWebPage(String URLstring, String parameters) {
                try {
                        URL url = new URL(URLstring + parameters);
                        URLConnection conn = url.openConnection();
                        // Get the response
                        BufferedReader rd = new BufferedReader(new 
InputStreamReader(conn
                                        .getInputStream()));
                        while ((s = rd.readLine()) != null) {
                                return s;
                        }
                } catch (Exception e) {
                        Log.e("SettingsDialog", "exception in callWebPage");
                }
                return "error";
        }
}

*it always return "error";

-- 
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en

Reply via email to