Monday, August 27, 2012

Re: [android-developers] How to send a string using HTTP GET from an android app

Here is what I have been able to put together - it just does not do anything when I launch it on my phone.
package com.example.awc;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;

import java.io.BufferedReader;
import java.io.IOException;
/** import java.io.InputStreamReader; */
import java.net.URI;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;

public class MainActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }
    public void executeHttpGet() throws Exception {
        BufferedReader in = null;
        try {
     /**     HttpClient client = new DefaultHttpClient(); */
            HttpGet request = new HttpGet();
          /**  HttpResponse response = client.execute(request); */


            } finally {
            if (in != null) {
                try {
                    in.close();
                    } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}


<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.awc"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="15" />

    <uses-permission android:name="android.permission.INTERNET"/>
 

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/title_activity_main" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

Any suggestions?


On Monday, 27 August 2012 11:57:25 UTC-4, MagouyaWare wrote:
Thanks Justin.
I have been Googling my as! off for days and my post here was an act of desperation!
Sorry if I showed any disrespect to you or the group members.

No worries... From your post there was no way to tell that you had put any effort into this before asking. 

That being said... I came up with a google search in about 5 seconds that looked like it had some promising links.  Did none of those links in the Google search provide you with the necessary info?

Thanks,
Justin Anderson
MagouyaWare Developer
http://sites.google.com/site/magouyaware


On Mon, Aug 27, 2012 at 9:22 AM, Rob <allan.robe...@gmail.com> wrote:
Thanks Justin.

I have been Googling my as! off for days and my post here was an act of desperation!

Sorry if I showed any disrespect to you or the group members.

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

No comments:

Post a Comment