Android failed to use HTTP method POST -


so, have code in activity (layout supporting user interface button triggers method onsaveregistrationclick):

public void onsaveregistrationclick (view view){      postdata();  }  public void postdata(){      httpclient httpclient = new defaulthttpclient();     httppost httppost = new httppost("http://www.mywebsite.com");      try      {         httpclient.execute(httppost);     } catch (exception e){         toast.maketext(this, "not working" , toast.length_short).show();     } } 

on website, have index.php on call saves 1 row in database helps me determine if android connected site. however, i'm getting exceptions on line httpclient.execute(httppost);. mistaking?

p.s. - have permission added in androidmanifest.xml (i added extra, i.e.:

<uses-permission android:name="android.permission.internet"/> <uses-permission android:name="android.permission.write_external_storage"></uses-permission>  <uses-permission android:name="android.permission.read_external_storage"/>  <uses-permission android:name="android.permission.internet"></uses-permission>  <uses-permission android:name="android.permission.access_network_state"></uses-permission>  <uses-permission android:name="android.permission.read_phone_state"></uses-permission>      <uses-permission android:name="android.permission.download_without_notification" /> 

the error must use thread , not function, try this:

new mytask().execute(); 

that call process

private class mytask extends asynctask<void, void, void> {      string textresult;     private exception exception;       @override     protected void doinbackground(void... voids)     { ...your code } 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -