07-25 14:27:41.218: E/AndroidRuntime(351): FATAL EXCEPTION: Thread-8
07-25 14:27:41.218: E/AndroidRuntime(351): java.lang.NullPointerException: println needs a message
07-25 14:27:41.218: E/AndroidRuntime(351): at android.util.Log.println_native(Native Method)
07-25 14:27:41.218: E/AndroidRuntime(351): at android.util.Log.e(Log.java:215)
07-25 14:27:41.218: E/AndroidRuntime(351): at commerce.app.lib.login.LoginScreen$1$1.run(LoginScreen.java:224)
07-25 14:27:42.848: E/WindowManager(351): Activity commerce.app.lib.login.LoginScreen has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@44f299e0 that was originally added here
07-25 14:27:42.848: E/WindowManager(351): android.view.WindowLeaked: Activity commerce.app.lib.login.LoginScreen has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@44f299e0 that was originally added here
07-25 14:27:42.848: E/WindowManager(351): at android.view.ViewRoot.<init>(ViewRoot.java:247)
07-25 14:27:42.848: E/WindowManager(351): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:148)
07-25 14:27:42.848: E/WindowManager(351): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
07-25 14:27:42.848: E/WindowManager(351): at android.view.Window$LocalWindowManager.addView(Window.java:424)
07-25 14:27:42.848: E/WindowManager(351): at android.app.Dialog.show(Dialog.java:241)
07-25 14:27:42.848: E/WindowManager(351): at android.app.ProgressDialog.show(ProgressDialog.java:107)
07-25 14:27:42.848: E/WindowManager(351): at android.app.ProgressDialog.show(ProgressDialog.java:90)
07-25 14:27:42.848: E/WindowManager(351): at commerce.app.lib.login.LoginScreen$1.onClick(LoginScreen.java:214)
07-25 14:27:42.848: E/WindowManager(351): at android.view.View.performClick(View.java:2408)
07-25 14:27:42.848: E/WindowManager(351): at android.view.View$PerformClick.run(View.java:8816)
07-25 14:27:42.848: E/WindowManager(351): at android.os.Handler.handleCallback(Handler.java:587)
07-25 14:27:42.848: E/WindowManager(351): at android.os.Handler.dispatchMessage(Handler.java:92)
07-25 14:27:42.848: E/WindowManager(351): at android.os.Looper.loop(Looper.java:123)
07-25 14:27:42.848: E/WindowManager(351): at android.app.ActivityThread.main(ActivityThread.java:4627)
07-25 14:27:42.848: E/WindowManager(351): at java.lang.reflect.Method.invokeNative(Native Method)
07-25 14:27:42.848: E/WindowManager(351): at java.lang.reflect.Method.invoke(Method.java:521)
07-25 14:27:42.848: E/WindowManager(351): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
07-25 14:27:42.848: E/WindowManager(351): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
07-25 14:27:42.848: E/WindowManager(351): at dalvik.system.NativeStart.main(Native Method)
07-25 14:27:43.328: I/Process(351): Sending signal. PID: 351 SIG: 9
私人CapstrovDatabaseOperations dbOperation; private Context mContext;
CheckBox remember;
CheckBox loginAutomatic;
EditText accountNumber;
EditText emailAddress;
EditText password;
int flag = 0;
ProgressDialog dialog;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.login_screen);
TextView txAreaName = (TextView) findViewById(R.id.areaName);
txAreaName.setText("");
accountNumber = (EditText) findViewById(R.id.ed_AccountNumber);
emailAddress = (EditText) findViewById(R.id.ed_Email);
password = (EditText) findViewById(R.id.ed_password);
remember = (CheckBox) findViewById(R.id.chk_Remember);
loginAutomatic = (CheckBox) findViewById(R.id.chk_Automatically);
accountNumber
.setBackgroundResource(android.R.drawable.editbox_background);
emailAddress
.setBackgroundResource(android.R.drawable.editbox_background);
password.setBackgroundResource(android.R.drawable.editbox_background);
mContext = getApplicationContext();
dbOperation = new CapstrovDatabaseOperations(mContext);
// Creating table in database
dbOperation.createTable();
// Opening Database in write mode
dbOperation.openForWrite();
// Showing All data from the database
Cursor cr = dbOperation.fetchData();
startManagingCursor(cr);
if (cr == null || cr.getCount() <= 0) {
flag = 0;
} else {
flag = 1;
cr.moveToFirst();
if (cr.getInt(cr.getColumnIndex("isRemember")) == 1) {
accountNumber.setText(cr.getString(cr
.getColumnIndex("capstrov_ac_no")));
emailAddress.setText(cr.getString(cr.getColumnIndex("email")));
password.setText(cr.getString(cr.getColumnIndex("password")));
remember.setChecked(true);
if (cr.getInt(cr.getColumnIndex("isAutomatic")) == 1) {
loginAutomatic.setChecked(true);
}
}
if (cr.getInt(cr.getColumnIndex("isAutomatic")) == 1) {
dialog = ProgressDialog.show(LoginScreen.this,
"Loading...", "Please wait...", true);
new Thread() {
public void run() {
try {
performBackgroundProcess();
} catch (Exception e) {
Log.e("tag", e.getMessage());
}
// dismiss the progress dialog
dialog.dismiss();
}
}.start();
}
}
cr.deactivate();
TextView tv_Register = (TextView) findViewById(R.id.link_Register);
tv_Register.setMovementMethod(LinkMovementMethod.getInstance());
TextView tv_Forgot = (TextView) findViewById(R.id.link_Forgot);
tv_Forgot.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent in_Forgot = new Intent().setClass(
getApplicationContext(), WebViewPage.class);
startActivity(in_Forgot);
}
});
Button btnLogin = (Button)findViewById(R.id.bt_Login);
btnLogin.setOnClickListener(loginlistener);
}
private boolean checkEmail(String email) {
return EMAIL_ADDRESS_PATTERN.matcher(email).matches();
}
@Override
public void onBackPressed() {
finish(); // finishes the current activity and doesn't save in stock
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.addCategory(Intent.CATEGORY_HOME);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
System.exit(0);
}
private OnClickListener loginlistener = new OnClickListener() {
public void onClick(View v) {
if (accountNumber.getText().toString() == null
|| emailAddress.getText().toString() == null
|| password.getText().toString() == null
|| accountNumber.getText().toString().equals("")
|| emailAddress.getText().toString().equals("")
|| password.getText().toString().equals("")) {
if (accountNumber.getText().toString() == null
|| accountNumber.getText().toString().equals("")) {
accountNumber
.setBackgroundResource(R.drawable.login_edit_text_focussed);
} else {
accountNumber
.setBackgroundResource(android.R.drawable.editbox_background);
}
if (emailAddress.getText().toString() == null
|| emailAddress.getText().toString().equals("")) {
emailAddress
.setBackgroundResource(R.drawable.login_edit_text_focussed);
} else {
emailAddress
.setBackgroundResource(android.R.drawable.editbox_background);
}
if (password.getText().toString() == null
|| password.getText().toString().equals("")) {
password.setBackgroundResource(R.drawable.login_edit_text_focussed);
} else {
password.setBackgroundResource(android.R.drawable.editbox_background);
}
Toast.makeText(mContext, "All Fields Are Mendatory",
Toast.LENGTH_LONG).show();
} else if (!checkEmail(emailAddress.getText().toString())) {
Toast.makeText(mContext, "Please enter valid Email Address",
Toast.LENGTH_LONG).show();
emailAddress
.setBackgroundResource(R.drawable.login_edit_text_focussed);
emailAddress.requestFocus();
accountNumber
.setBackgroundResource(android.R.drawable.editbox_background);
password.setBackgroundResource(android.R.drawable.editbox_background);
} else {
emailAddress
.setBackgroundResource(android.R.drawable.editbox_background);
dialog = ProgressDialog.show(LoginScreen.this, "Loading...",
"Please wait...", true);
Log.i(":::::::::::::::::::::", dialog.toString());
new Thread() {
public void run() {
try {
performBackgroundProcess();
} catch (Exception e) {
Log.i("###############", "Catch Block $$$$$$$$$$$$$$$$$$");
Log.e("tag", e.getMessage());
}
// dismiss the progress dialog
dialog.dismiss();
}
}.start();
}
}
};
private void performBackgroundProcess() {
String authenticationLoginResponse = null;
String pst = null;
String accNumber = accountNumber.getText().toString();
String emailAddrs = emailAddress.getText().toString();
String pass = password.getText().toString();
int isRem;
int isAuto;
if (remember.isChecked()) {
isRem = 1;
} else {
isRem = 0;
}
if (loginAutomatic.isChecked()) {
isAuto = 1;
} else {
isAuto = 0;
}
String envelope1 = "<req>" + "<channel>10</channel>" + ""
+ "<system>CAPSTROV</system>" + "<persist>0</persist>"
+ "<device>10B23T12SA</device>" + "<acno>" + accNumber
+ "</acno>" + "<email>" + emailAddrs + "</email>" + "<pass>"
+ pass + "</pass>" + "</req>";
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("requestXml", envelope1);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
Object response = null;
try {
androidHttpTransport.call(SOAP_ACTION, envelope);
response = envelope.getResponse();
authenticationLoginResponse = response.toString();
Log.i("&&&&&&&&&&&&&&&&&&&&&&", authenticationLoginResponse);
} catch (Exception e) {
e.printStackTrace();
}
try {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse(new InputSource(new StringReader(
authenticationLoginResponse)));
// normalize the document
doc.getDocumentElement().normalize();
NodeList detnode = doc.getElementsByTagName("det");
Node node1 = detnode.item(0);
Element fstelement1 = (Element) node1;
NodeList reglist1 = fstelement1.getElementsByTagName("pst").item(0)
.getChildNodes();
Node nvalue1 = (Node) reglist1.item(0);
pst = nvalue1.getNodeValue();
SharedPreferences myPrefs = this.getSharedPreferences("myPrefs", MODE_WORLD_READABLE);
SharedPreferences.Editor prefsEditor = myPrefs.edit();
prefsEditor.putString("pstValue",pst);
prefsEditor.commit();
LoginScreenData loginScreenData = new LoginScreenData();
loginScreenData.setPst(pst);
if (flag == 0) {
// Inserting values into login Table
dbOperation.insertData(accNumber, emailAddrs, pass, isRem,
isAuto, pst);
} else {
// Updating values into login Table
dbOperation.updateData(accNumber, emailAddrs, pass, isRem,
isAuto, pst);
}
dbOperation.close();
} catch (Exception e) {
e.printStackTrace();
}
if (pst.equals("")) {
dialog = ProgressDialog.show(LoginScreen.this, "Loading...",
"Please wait...", true);
dialog.show();
} else {
Intent intent = new Intent();
intent.setClass(getApplicationContext(), MainScreen.class);
intent.putExtra("pst", pst);
startActivity(intent);
}
Log.i("*************", dialog.toString());
}
}
答案 0 :(得分:0)
E/AndroidRuntime(351): java.lang.NullPointerException: println needs a message 07-25 14:27:41.218:
你完成了你的活动然后去了意图?为什么?完成Intent然后完成()
public void onBackPressed() {
Intent i = new Intent(this, actio_main.class);
i.setFlages(Intent.FLAG_ACTIVITY_CLEAR_TOP);
i.addCategory(Intent.CATEGORY_HOME);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
finish();