[android-developers] Re: Need some help troubleshooting my app

2012-01-20 Thread James
Does the PHP page work when you use it from the web browser on your
phone?
On Jan 16, 5:53 pm, jp bears0...@gmail.com wrote:
 Can anyone help me get my app connected to my database. I want a user
 to enter information in the registration page and have that data
 update and store in mysql database. For some reason though it is not
 working. My exception error is being caught and saying my toast
 message can not connect and no info is passed to the database. What
 am I doing wrong?? Thanks in advance for any help

 Here is my java

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

 import org.apache.http.HttpResponse;
 import org.apache.http.NameValuePair;
 import org.apache.http.client.HttpClient;
 import org.apache.http.client.ResponseHandler;
 import org.apache.http.client.entity.UrlEncodedFormEntity;
 import org.apache.http.client.methods.HttpPost;
 import org.apache.http.impl.client.BasicResponseHandler;
 import org.apache.http.impl.client.DefaultHttpClient;
 import org.apache.http.message.BasicNameValuePair;

 import android.app.Activity;
 import android.content.Intent;
 import android.content.SharedPreferences;
 import android.os.Bundle;
 import android.preference.PreferenceManager;
 import android.view.View;
 import android.widget.Button;
 import android.widget.CheckBox;
 import android.widget.EditText;
 import android.widget.TextView;
 import android.widget.Toast;

 public class LoginJ extends Activity {
     Button login;
     String name=,pass=, EMAIL=;
     EditText username,password, email;
     TextView tv;
     byte[] data;
     HttpPost httppost;
     StringBuffer buffer;
     HttpResponse response;
     HttpClient httpclient;
     InputStream inputStream;
     SharedPreferences app_preferences ;
     ListNameValuePair nameValuePairs;
     CheckBox check;
     public void onCreate(Bundle savedInstanceState)
     {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.login);
         app_preferences =
 PreferenceManager.getDefaultSharedPreferences(this);
         username = (EditText) findViewById(R.id.username);
         password = (EditText) findViewById(R.id.password);
         email = (EditText) findViewById(R.id.email);
         login = (Button) findViewById(R.id.login);
         check = (CheckBox) findViewById(R.id.check);

         String Str_user =
 app_preferences.getString(username,0 );
         String Str_pass = app_preferences.getString(password,
 0);
         String Str_EMAIL = app_preferences.getString(email, 0);
         String Str_check = app_preferences.getString(checked,
 no);
         if(Str_check.equals(yes)) {
             username.setText(Str_user);
             password.setText(Str_pass);
             email.setText(Str_EMAIL);
             check.setChecked(true);

         }
         login.setOnClickListener(new View.OnClickListener()
         {

             public void onClick(View v) {
                 name = username.getText().toString();
                 pass = password.getText().toString();
                 EMAIL = email.getText().toString();
                 String Str_check2 =
 app_preferences.getString(checked, no);
                 if(Str_check2.equals(yes))
                 {
                     SharedPreferences.Editor editor =
 app_preferences.edit();
                     editor.putString(username, name);
                    editor.putString(password, pass);
                    editor.putString(email, EMAIL);
                      editor.commit();

                 }

                 if(name.trim().equals() || pass.trim().equals() ||
 EMAIL.trim().equals())
                 {
                     Toast.makeText(LoginJ.this, Blank Field..Please
 Enter, Toast.LENGTH_LONG).show();
                 }
                 else{

                 try{

                      httpclient = new DefaultHttpClient();
                                        httppost = new HttpPost(http://
 10.0.2.2/AppConnection/main.php);

                                             // Add your data
                                             nameValuePairs = new
 ArrayListNameValuePair(3);
                                            nameValuePairs.add(new
 BasicNameValuePair(UserName, name.trim()));
                                             nameValuePairs.add(new
 BasicNameValuePair(Password, pass.trim()));
                                             nameValuePairs.add(new
 BasicNameValuePair(email, pass.trim()));
                                             httppost.setEntity(new
 UrlEncodedFormEntity(nameValuePairs));

                                             // Execute HTTP Post
 Request
                                             response =
 httpclient.execute(httppost);
                                             inputStream =
 response.getEntity().getContent();

                                             ResponseHandlerString
 responseHandler = new BasicResponseHandler();
                                       

[android-developers] Re: Need some help troubleshooting my app

2012-01-16 Thread Jonathan S
Are you sure this is http:// 10.0.2.2/AppConnection/main.php correct?

-- 
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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Re: Need some help troubleshooting my app

2012-01-16 Thread Harri Smått
Unfortunate fact there's no way to figure it out for the rest of us as it's 
within private IP space.

--
Harri

On Jan 16, 2012, at 9:32 PM, Jonathan S wrote:

 Are you sure this is http:// 10.0.2.2/AppConnection/main.php correct?
 
 -- 
 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+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en

-- 
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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en