android error to run project




  1. An internal error occurred during: "Launching New_configuration".

  2. java.lang.StackOverflowError.

  3. You know how it solve

  4. I have pass from 1 page to another page.

  5. give option exit workbench or not.


  6. I can send my manifest file also



    package com.exam.reg_log;
    import java.io.BufferedReader;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    import java.util.ArrayList;

    import org.apache.http.HttpEntity;
    import org.apache.http.HttpResponse;
    import org.apache.http.NameValuePair;
    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.json.JSONObject;



    import android.support.v7.app.ActionBarActivity;
    import android.content.Context;
    import android.content.Intent;
    import android.os.Bundle;
    import android.os.StrictMode;
    import android.util.Log;
    import android.view.Menu;
    import android.view.MenuItem;
    import android.view.View;
    import android.widget.Button;
    import android.widget.EditText;
    import android.widget.Toast;


    public class MainActivity extends ActionBarActivity {


    String name;
    String phn;
    String email;
    String pass;
    InputStream is=null;
    String result=null;
    String line=null;
    int code;
    Button insert,login;
    final Context context = this;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
    StrictMode.setThreadPolicy(policy);

    final EditText e_name=(EditText) findViewById(R.id.editText1);
    final EditText e_phn=(EditText) findViewById(R.id.editText2);
    final EditText e_email=(EditText) findViewById(R.id.editText3);
    final EditText e_pass=(EditText) findViewById(R.id.editText4);
    insert=(Button) findViewById(R.id.button1);
    login = (Button) findViewById(R.id.button2);

    login.setOnClickListener(new View.OnClickListener() {


    @Override
    public void onClick(View v) {
    // TODO Auto-generated method stub

    Intent intent = new Intent(context, Login.class);
    startActivity(intent);

    }
    });
    insert.setOnClickListener(new View.OnClickListener() {

    @Override
    public void onClick(View arg0) {
    // TODO Auto-generated method stub

    name = e_name.getText().toString();
    phn = e_phn.getText().toString();
    email = e_email.getText().toString();
    pass = e_pass.getText().toString();

    insert();

    }
    });
    }
    public void insert()
    {

    HttpClient httpclient = new DefaultHttpClient();
    HttpPost httppost = new HttpPost("http://ift.tt/1vps91V");
    try
    {
    ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();

    nameValuePairs.add(new BasicNameValuePair("name",name));
    nameValuePairs.add(new BasicNameValuePair("phn",phn));
    nameValuePairs.add(new BasicNameValuePair("email",email));
    nameValuePairs.add(new BasicNameValuePair("pass",pass));
    Log.d("smit output",name + phn + email + pass);
    //HttpClient httpclient = new DefaultHttpClient();
    // HttpPost httppost = new HttpPost("http://ift.tt/PeJwTB");
    httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
    HttpResponse response = httpclient.execute(httppost);
    HttpEntity entity = response.getEntity();
    is = entity.getContent();
    Log.e("pass 1", "connection success ");
    }
    catch(Exception e)
    {
    Log.e("Fail 1", e.toString());
    Toast.makeText(getApplicationContext(), "Invalid IP Address",
    Toast.LENGTH_LONG).show();
    }

    try
    {
    BufferedReader reader = new BufferedReader
    (new InputStreamReader(is,"iso-8859-1"),8);
    StringBuilder sb = new StringBuilder();
    while ((line = reader.readLine()) != null)
    {
    sb.append(line + "\n");
    }
    is.close();
    result = sb.toString();
    Log.e("pass 2", "connection success ");
    }
    catch(Exception e)
    {
    Log.e("Fail 2", e.toString());
    }

    try
    {
    /*
    * JSONArray jArray = new JSONArray(result);
    for(int i=0;i<jArray.length();i++){
    JSONObject json_data = jArray.getJSONObject(i);
    Log.i("log_tag","uID: "+json_data.getInt("uID")+
    ", uName: "+json_data.getString("uName")+
    ", uPass: "+json_data.getString("uPass")
    );
    }
    */
    Log.d("smit output",result);
    JSONObject json_data = new JSONObject(result);
    /* for(int i=0;i<json_data.length();i++){
    JSONObject json_data1 = json_data.getJSONObject(i);
    Log.i("log_tag","uID: "+json_data1.getInt("id")+
    ", uName: "+json_data1.getString("name")+
    ", uphn: "+json_data1.getString("phn") +
    ", uemail: "+json_data1.getString("email") +
    ", upass: "+json_data1.getString("pass")

    );
    }*/
    code=(json_data.getInt("code"));

    if(code==1)
    {
    Toast.makeText(getBaseContext(), "Inserted Successfully",
    Toast.LENGTH_SHORT).show();
    }
    else
    {
    Toast.makeText(getBaseContext(), "Sorry, Try Again",
    Toast.LENGTH_LONG).show();
    }
    }
    catch(Exception e)
    {
    Log.e("Fail 3", e.toString());
    }
    }

    @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;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();
    if (id == R.id.action_settings) {
    return true;
    }
    return super.onOptionsItemSelected(item);
    }
    }

    // menifest file ......................

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



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

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

    <application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
    android:name=".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>
    <activity
    android:name=".Login"
    android:label="@string/title_activity_login" >
    <intent-filter>
    <action android:name="android.intent.action.MAIN" />

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



No comments:

Post a Comment