FAQ
Can anyone please help me on this

logcat

03-22 03:33:47.816: I/RESPONSE(7552): <!DOCTYPE html PUBLIC "-//W3C//DTD
XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd<http://www.google.com/url?q=http%3A%2F%2Fwww.w3.org%2FTR%2Fxhtml1%2FDTD%2Fxhtml1-strict.dtd&sa=D&sntz=1&usg=AFQjCNHNsVQ5b0cvVPgxg0Xh4xeYLHef5w>
">
03-22 03:33:47.816: I/RESPONSE(7552): <html xmlns="
" rel="nofollow">http://www.w3.org/1999/xhtml">
03-22 03:33:47.816: I/RESPONSE(7552): <head>
03-22 03:33:47.816: I/RESPONSE(7552): <meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1"/>
03-22 03:33:47.816: I/RESPONSE(7552): <title>404 - File or directory not
found.</title>

code

*package* com.example.androidhttp;


*import* java.io.IOException;

*import* java.io.UnsupportedEncodingException;

*import* java.util.ArrayList;

*import* java.util.List;


*import* org.apache.http.HttpEntity;

*import* org.apache.http.HttpResponse;

*import* org.apache.http.NameValuePair;

*import* org.apache.http.client.ClientProtocolException;

*import* org.apache.http.client.HttpClient;

*import* org.apache.http.client.entity.UrlEncodedFormEntity;

*import* org.apache.http.client.methods.HttpPost;

*import* org.apache.http.impl.client.DefaultHttpClient;

*import* org.apache.http.message.BasicNameValuePair;

*import* org.apache.http.util.EntityUtils;


*import* android.app.Activity;

*import* android.os.AsyncTask;

*import* android.os.Bundle;

*import* android.util.Log;

*import* android.view.Menu;

*import* android.widget.TextView;


*public* *class* MainActivity *extends* Activity {

  StringBuffer sb ;

@Override

*protected* *void* onCreate(Bundle savedInstanceState) {

*super*.onCreate(savedInstanceState);

setContentView(R.layout.*activity_main*);

//new DoSampleHttpPostRequest();

*new* SendData().doInBackground();

  }

*private* *class* SendData *extends* AsyncTask<String, Integer, Void> {

      *protected* *void* doInBackground() {

       TextView txtView = (TextView)findViewById(R.id.*tv*);

        txtView.setText("biatch");

// Create a new HttpClient and Post Header

HttpClient client = *new* DefaultHttpClient();

String postURL = ("http://74.94.99.101/gcm_server/register.php");

HttpPost post = *new* HttpPost(postURL);

*try* {

     // Add the data

String s=
"APA91bHHnT8yd2Cdku2QvFWymt3YvIaxQQ7UZkNcHbWfGKj3dY-DommmlD-LtJuIjSm_DSEUSJzxQoOeGQgs1-JoMCEr31f8tfF5pqjaKhM2GB3JulMiswHIhFZ7U3pXKHvPtadbHH6xl8hB8XKlL4UFc17OeKfNmED-yzSpyVkDqODupqrZvvs"
;



     List<NameValuePair> pairs = *new* ArrayList<NameValuePair>(3);

     pairs.add(*new* BasicNameValuePair("name", "jim"));

     pairs.add(*new* BasicNameValuePair("email","googleman@gmail.com"));

     pairs.add(*new* BasicNameValuePair("regId", s));

     UrlEncodedFormEntity uefe = *new* UrlEncodedFormEntity(pairs);

     post.setEntity(uefe);

     // Execute the HTTP Post Request

     HttpResponse response = client.execute(post);

     // Convert the response into a String

     HttpEntity resEntity = response.getEntity();

     *if* (resEntity != *null*) {

         Log.*i*("RESPONSE", EntityUtils.*toString*(resEntity));

     }

} *catch* (UnsupportedEncodingException uee) {

     uee.printStackTrace();

} *catch* (ClientProtocolException cpe) {

     cpe.printStackTrace();

} *catch* (IOException ioe) {

     ioe.printStackTrace();

}



      }


  *protected* *void* onProgressUpdate() {

     //called when the background task makes any progress

  }


   *protected* *void* onPreExecute() {

      //called before doInBackground() is started

  }

  *protected* *void* onPostExecute() {

      //called after doInBackground() has finished

  }




@Override

*protected* Void doInBackground(String... params) {

// *TODO* Auto-generated method stub

*return* *null*;

}

   }

  @Override

*public* *boolean* onCreateOptionsMenu(Menu menu) {

// Inflate the menu; this adds items to the action bar if it is present.

getMenuInflater().inflate(R.menu.*main*, menu);

*return* *true*;

}


}

manifest

<?xml version=*"1.0"* encoding=*"utf-8"*?>

<manifest xmlns:android=*"http://schemas.android.com/apk/res/android
<http://schemas.android.com/apk/res/android>"*

     package=*"com.example.androidhttp"*

     android:versionCode=*"1"*

     android:versionName=*"1.0"* >


     <uses-sdk

         android:minSdkVersion=*"8"*

           />




     <application

         android:permission=*"android.permission.INTERNET"*



         android:allowBackup=*"true"*

         android:icon=*"@drawable/ic_launcher"*

         android:label=*"@string/app_name"*

         android:theme=*"@style/AppTheme"* >

         <activity

             android:name=*"com.example.androidhttp.MainActivity"*

             android:label=*"@string/app_name"* >

             <intent-filter>

                 <action android:name=*"android.intent.action.MAIN"* />


                 <category android:name=*"android.intent.category.LAUNCHER"*
/>

             </intent-filter>

         </activity>

             <receiver

             android:name=*"com.google.android.gcm.GCMBroadcastReceiver"*

             android:permission=*"com.google.android.c2dm.permission.SEND"* >

             <intent-filter>



                 <!-- Receives the actual messages. -->

                 <action android:name=
*"com.google.android.c2dm.intent.RECEIVE"* />

                 <!-- Receives the registration id. -->

                 <action android:name=
*"com.google.android.c2dm.intent.REGISTRATION"* />



                 <category android:name=*"com.androidexample.gcm"* />

             </intent-filter>

         </receiver>



         <service android:name=*"com.androidexample.gcm.GCMIntentService"* />



     </application>

<!-- GCM connects to Internet Services. -->

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



     <!-- GCM requires a Google account. -->

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



     <!-- Keeps the processor from sleeping when a message is received. -->

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



     <!-- Creates a custom permission so only this app can receive its
messages. -->

     <permission

         android:name=*"com.androidexample.gcm.permission.C2D_MESSAGE"*

         android:protectionLevel=*"signature"* />



     <uses-permission android:name=
*"com.androidexample.gcm.permission.C2D_MESSAGE"* />



     <!-- This app has permission to register and receive data message. -->

     <uses-permission android:name=
*"com.google.android.c2dm.permission.RECEIVE"* />



     <!-- Network State Permissions to detect Internet status -->

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



     <!-- Permission to vibrate -->

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

</manifest>

have gcm.jar in my libs dir

So many thanks!!! Am join' crazy trying a fix.

~googleman

--
You received this message because you are subscribed to the Google Groups "android-gcm" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-gcm+unsubscribe@googlegroups.com.
To post to this group, send email to android-gcm@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-gcm/4c5d43ec-753c-41cf-909b-877e04c7a7ad%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupandroid-gcm @
categoriesandroid
postedMar 22, '14 at 2:47p
activeMar 22, '14 at 2:47p
posts1
users1
websitedeveloper.android.com...

1 user in discussion

Googleman: 1 post

People

Translate

site design / logo © 2019 Grokbase