- Home /
fatal exception: main in android
main activity: file package com.example.webservicei;
import org.ksoap2.SoapEnvelope; import org.ksoap2.serialization.SoapObject; import org.ksoap2.serialization.SoapSerializationEnvelope; import org.ksoap2.transport.HttpTransportSE;
import android.annotation.SuppressLint; import android.app.Activity; import android.app.ProgressDialog; import android.content.Intent; import android.os.AsyncTask; import android.os.Bundle; import android.os.StrictMode; import android.util.Log; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText; import android.widget.Toast;
public class MainActivity extends Activity implements OnClickListener { Button login,logout; ProgressDialog pDialog; SoapObject response = null; String value = "perumal@otr-ict.in",loginResponse; String value1 ="perumal1234",loginResponse1; String value2 = "loginResponse2"; String loginResponse2 = "loginResponse+loginResponse1"; EditText username,password; private static String mNAMESPACE="http://tempuri.org/"; private static String SOAP_ACTION = "http://tempuri.org/ValidateUser"; private static String mURL="http://192.168.0.5:81/GoodListingWebService/service.asmx?op=ValidateUser"; private static String USERNAME="email"; private static String PASSWORD="Password"; private static String METHODNAME="ValidateUser"; public static CharSequence progress_message; public static CharSequence progress_title; @SuppressLint("NewApi") @Override
protected void onCreate(Bundle savedInstanceState)
{
//super.onCreate(savedInstanceState);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity);
if (android.os.Build.VERSION.SDK_INT > 9)
{
StrictMode.ThreadPolicy policy =
new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
}
login=(Button)findViewById(R.id.login);
//logout=(Button)findViewById(R.id.login);
username = (EditText)findViewById(R.id.userbutton);
password = (EditText)findViewById(R.id.passbutton);
login.setOnClickListener(this);
// logout.setOnClickListener(this);
}
public void onClick(View arg0)
{
switch(arg0.getId())
{
/*case R.id.logout:
finish();
moveTaskToBack(true); break;*/ case R.id.login: if(username.getText().toString().equalsIgnoreCase("")|| username.getText().toString().equalsIgnoreCase(null)) {
//Toast.makeText(getApplicationContext(), R.string.usernametoast, Toast.LENGTH_SHORT).show();
}
else if
(password.getText().toString().equalsIgnoreCase("")|| password.getText().toString().equalsIgnoreCase(null))
{
//Toast.makeText(getApplicationContext(), R.string.passwordtoast, Toast.LENGTH_SHORT).show();
}
else
{
//if(ConstantsUsed.isnetworkConnected(getApplicationContext()))
if(ConstantsUsed.isnetworkConnected(getApplicationContext()))
{
new LoginAsyncTask().execute();
}
else
{
Toast.makeText(getApplicationContext(),ConstantsUsed.internet_connection, Toast.LENGTH_LONG).show();
}
}
// Intent intent = new Intent(LoginPage.this,HomePage.class);
// intent.putExtra("mail", username.getText().toString());
// startActivity(intent);
break;
default:
break;
}
}
class LoginAsyncTask extends AsyncTask<String, Void, Void>
{
@Override
protected void onPreExecute()
{
pDialog = new ProgressDialog(MainActivity.this);
pDialog.setTitle(MainActivity.progress_title);
pDialog.setMessage(MainActivity.progress_message);
pDialog.show();
super.onPreExecute();
}
@Override
protected Void doInBackground(String... params)
{
SoapObject request = new SoapObject(mNAMESPACE, METHODNAME);
//Use this to add parameters
String userna = username.getText().toString();
String passw = password.getText().toString();
request.addProperty(USERNAME,userna);
request.addProperty(PASSWORD,passw);
//Declare the version of the SOAP request
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
envelope.dotNet = true;
try {
HttpTransportSE androidHttpTransport = new HttpTransportSE(mURL);
//this is the actual part that will call the webservice
androidHttpTransport.call(SOAP_ACTION, envelope);
// Get the SoapResult from the envelope body
SoapObject result = (SoapObject)envelope.bodyIn;
if(result != null)
{
loginResponse = result.getProperty(0).toString();
}
else
{
Toast.makeText(getApplicationContext(), "No Response",Toast.LENGTH_LONG).show();
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(Void result)
{
super.onPostExecute(result);
if (pDialog != null && pDialog.isShowing())
{
pDialog.dismiss();
if(loginResponse2.matches("loginResponse"+"loginResponse1"))
//if(loginResponse == ("username")) equals (loginResponse1 == ("password"))
//if(loginResponse.matches("USERNAME") equals (loginResponse1.matches("PASSWORD"))
{
Intent i = new Intent(MainActivity.this, ConstantsUsed.class);
// i.putExtra("userna", username.getText().toString());
i.putExtra("loginResponse", true);
startActivity(i);
}
else{
Intent i = new Intent(MainActivity.this,ConstantsUsed.class);
i.putExtra("loginResponse", false);
startActivity(i);
Toast.makeText(getApplicationContext(), "username and password was not match", Toast.LENGTH_LONG).show();
}
//loginResponse = result.toString().valueOf(true);
/*if(!loginResponse.equalsIgnoreCase("") )
{*/ /if(result != null) { loginResponse = result.equals(SOAP_ACTION); } else { Toast.makeText(getApplicationContext(), "No Response",Toast.LENGTH_LONG).show(); }/
if (result != null){
result.equals(loginResponse2);
loginResponse2 = result.toString().valueOf(true);
// loginResponse = response.getName().toString().valueOf(true);
// loginResponse = result.equals(mURL);
// loginResponse = SOAP_ACTION.toString().valueOf(true);
// loginResponse = result.TYPE.getName().valueOf(true);
// loginResponse = String.valueOf(true);
// loginResponse = result.TYPE.toString().valueOf(true);
// loginResponse = result.toString().valueOf(true);
// loginResponse = result.toString().valueOf(true);
// loginResponse = result.getClass().getName().toString().valueOf(true);
// loginResponse = result.TYPE.getName().valueOf(true);
// loginResponse = response.getName().valueOf(true);
// loginResponse = result.toString().valueOf(true);
Toast.makeText(getApplicationContext(), "got response", Toast.LENGTH_LONG).show();
}
else {
result = null;
// loginResponse = result.equals(get().toString().valueOf(false));
// loginResponse = SOAP_ACTION.toString().valueOf(false);
// loginResponse = android.widget.AutoCompleteTextView.Validator.class.toString().valueOf(false);
// loginResponse = result.TYPE.toString().valueOf(false);
// loginResponse = result.toString().valueOf(false);
// loginResponse = result.toString().valueOf(false);
// loginResponse = result.getClass().getName().toString().valueOf(false);
// loginResponse = String.valueOf(false);
// loginResponse = result.TYPE.getName().valueOf(false);
loginResponse = result.TYPE.getName().valueOf(false);
Toast.makeText(getApplicationContext(), "NoResponse", Toast.LENGTH_LONG).show();
}
Log.v("@@@@@@@@@@@@@@@@", "loginResponse"+loginResponse);
/*if(loginResponse.equalsIgnoreCase("True"))
{ Intent intent = new Intent(MainActivity.this,HomePage.class); intent.putExtra("userna", username.getText().toString()); startActivity(intent); } else { Toast.makeText(getApplicationContext(), "Username & Password was Not Match",Toast.LENGTH_LONG).show(); } // Log.v("@@@@@@@@@@@@@@@", "loginResponse"+loginResponse);
if(loginResponse.equalsIgnoreCase("True")) { Intent intent = new Intent(MainActivity.this,ConstantsUsed.class); intent.putExtra("mail", username.getText().toString()); startActivity(intent); }
else { Toast.makeText(getApplicationContext(), "Username & Password was Not Match",Toast.LENGTH_LONG).show(); } }
else { Toast.makeText(getApplicationContext(), "Server Error",Toast.LENGTH_LONG).show(); } }*/ } } } }
Your answer
![](https://koobas.hobune.stream/wayback/20220613120028im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
App crashes on Android 7.11 2 Answers
What is TA Load in the Android internal profiler? 0 Answers
Android app killed after returning from Unity module 0 Answers
Problems porting a Unity game to android 1 Answer
Solving a crash with help from logcat 0 Answers