我想要紧急帮助, 当我点击“ffp”imagebutton时,我想去另一个活动,但每次点击它,我都会收到一个错误,我该怎么办,除了调用那个按钮,一切都还好。如果我应该使用AsynchTask那么如何? 我的布局XML文件没有错误我多次检查它。 ,我在下面提供了我的LoginActivity和清单:
package com.aminmousavi.safetransaction;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.TextView;
import android.widget.Toast;
import android.os.StrictMode;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
public class LoginActivity extends Activity {
private static final String SOAP_ACTION = "urn:safewsdl#loginuser";
private static final String METHOD_NAME = "loginuser";
private static final String NAMESPACE = "urn:safewsdl";
private static final String URL = "http://10.0.2.2/WebServiceSOAP/webs.php";
SoapObject request;
SoapSerializationEnvelope envelope;
HttpTransportSE httpTransport;
Object response;
StrictMode.ThreadPolicy policy;
@Override
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.login);
if (android.os.Build.VERSION.SDK_INT > 9) {
policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
}
Button btnLogin = (Button) findViewById(R.id.btnLogin);
btnLogin.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
EditText emailet = (EditText)findViewById(R.id.emailet);
EditText passet = (EditText) findViewById(R.id.passet);
request = new SoapObject(NAMESPACE, METHOD_NAME);
//SoapObject
request.addProperty("email", emailet.getText().toString());
request.addProperty("password", passet.getText().toString());
envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
httpTransport = new HttpTransportSE(URL);
try
{
httpTransport.call(SOAP_ACTION, envelope);
response = envelope.getResponse();
Toast.makeText(getBaseContext(), response.toString(), Toast.LENGTH_LONG).show();
}
catch (Exception exception)
{
Toast.makeText(getBaseContext(), exception.toString(), Toast.LENGTH_LONG).show();
}
}
});
TextView registerScreen = (TextView) findViewById(R.id.link_to_register);
// Listening to register new account link
registerScreen.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
//Switching to Register screen
Intent i = new Intent(getApplicationContext(), RegisterActivity.class);
startActivity(i);
}
});
ImageButton ffp = (ImageButton) findViewById(R.id.fingerp);
ffp.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
try{
startActivity(new Intent("com.aminmousavi.SecondActivity"));
}
catch(Exception e){
e.printStackTrace();
Log.d("AppErorr", e.getMessage());
Toast.makeText(getBaseContext(), "Error", Toast.LENGTH_LONG).show();
}
}
});
}
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.aminmousavi.safetransaction"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.aminmousavi.safetransaction.LoginActivity"
android:label="Login to your Account" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- Entry for RegisterActivity.class -->
<activity android:name=".RegisterActivity"
android:label="Register New Account">
</activity>
<!-- Entry for FiongerprintActivity.class -->
<activity android:name=".SecondActivity"
android:label="Second Activity">
</activity>
</application>
答案 0 :(得分:0)
尝试:
startActivity(new Intent(LoginActivity.this, SecondActivity.class));
而不是:
startActivity(new Intent("com.aminmousavi.SecondActivity"));
答案 1 :(得分:0)
适合我:
startActivity(new Intent(LoginActivity.this, com.aminmousavi.SecondActivity.class));