登录活动没有响应

时间:2014-06-24 11:36:18

标签: java android xml

我正在android上构建一个销售应用程序。该应用程序响应良好,但当我从主活动注销并进入Login活动并输入用户名和密码或默认情况下写入并按Enter键它将不会移至Main活动,它仍然存在在Login活动。这是在第二次登录时发生的。 logcat的:

06-24 08:11:25.550: D/User Name(1210): testuser3 Password  admin
06-24 08:11:25.550: E/SoundPool(381): error loading /system/media/audio/ui/KeypressStandard.ogg
06-24 08:11:25.550: W/AudioService(381): Soundpool could not load file: /system/media/audio/ui/KeypressStandard.ogg
06-24 08:11:25.560: E/SoundPool(381): error loading /system/media/audio/ui/KeypressSpacebar.ogg
06-24 08:11:25.560: W/AudioService(381): Soundpool could not load file: /system/media/audio/ui/KeypressSpacebar.ogg
06-24 08:11:25.560: E/SoundPool(381): error loading /system/media/audio/ui/KeypressDelete.ogg
06-24 08:11:25.560: W/AudioService(381): Soundpool could not load file: /system/media/audio/ui/KeypressDelete.ogg
06-24 08:11:25.560: E/SoundPool(381): error loading /system/media/audio/ui/KeypressReturn.ogg
06-24 08:11:25.560: W/AudioService(381): Soundpool could not load file: /system/media/audio/ui/KeypressReturn.ogg
06-24 08:11:25.560: E/SoundPool(381): error loading /system/media/audio/ui/KeypressInvalid.ogg
06-24 08:11:25.560: W/AudioService(381): Soundpool could not load file: /system/media/audio/ui/KeypressInvalid.ogg
06-24 08:11:25.560: W/AudioService(381): onLoadSoundEffects(), Error -1 while loading samples
06-24 08:11:25.560: D/User Name(1210): testuser4 Password  admin
06-24 08:11:25.560: D/User Name(1210): Wasiraza Password  12345
06-24 08:11:25.560: D/User Name(1210): wasiuser Password  12345
06-24 08:11:25.560: D/User Name(1210): zeeshansabri Password  Ha5hir786
06-24 08:11:29.610: D/ConnectivityService(381): Sampling interval elapsed, updating statistics ..
06-24 08:11:29.650: I/ProcessStatsService(381): Prepared write state in 19ms
06-24 08:11:29.660: D/ConnectivityService(381): Done.
06-24 08:11:29.660: D/ConnectivityService(381): Setting timer for 720seconds
06-24 08:11:29.680: I/ProcessStatsService(381): Pruning old procstats: /data/system/procstats/state-2014-06-21-08-27-00.bin
06-24 08:12:00.000: I/ActivityManager(381): Killing 638:com.android.externalstorage/u0a6 (adj 15): empty for 1804s
06-24 08:12:00.000: I/ActivityManager(381): Killing 569:com.android.printspooler/u0a39 (adj 15): empty for 1815s

通过log标签:SoundPool,通过日志消息:错误加载/system/media/audio/ui/KeypressInvalid.ogg,由PID:381,按应用程序名称:system_process这些是logcat中的错误

当我重新启动应用程序时,应用程序可以启动。这是代码

package com.robin.saeedghani;

import java.util.ArrayList;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.robin.ApiCalls.APICalls;
import com.robin.ApiCalls.APIParameters;

TerritoryController c1 = new TerritoryController(LoginActivity.this);
private Button buttonSubmit;
private EditText editTextUserId, editTextPassword;
private ArrayList<Users> usersArrayList = new ArrayList<Users>();

Boolean isInternetPresent = false, userFound = false;

// Connection detector class
ConnectionDetector cd;

@Override
protected void onCreate(Bundle savedInstanceState) {
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);
    cd = new ConnectionDetector(getApplicationContext());
        setUpViews();

}

@Override
public void onBackPressed() {
    super.onBackPressed();
    finish();

}

private void getUsers() {

    APICalls obj = new APICalls(LoginActivity.this,
                APIParameters.ACTION_GETLOGIN, null, LoginActivity.this);
    String params = "Get";
    obj.execute(params);
}

private void setUpViews() {
    cd = new ConnectionDetector(getApplicationContext());
    buttonSubmit = (Button) findViewById(R.id.buttonSubmit);
    buttonSubmit.setOnClickListener(this);

    editTextUserId = (EditText) findViewById(R.id.editTextUserId);
    editTextPassword = (EditText) findViewById(R.id.editTextPassword);

    isInternetPresent = cd.isConnectingToInternet();

    // check for Internet status
    if (isInternetPresent) {
        getUsers();

    } else {
        getUserSQlite();
    }
}

@Override
public void onClick(View v) {
    // TODO Auto-generated method stub
    if (v.getId() == R.id.buttonSubmit) {

        InputMethodManager imm = (InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE);
        imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);

        isInternetPresent = cd.isConnectingToInternet();
        if (usersArrayList.size() < 0) {
            getUserSQlite();
            if (usersArrayList.size() < 0) {
                if (isInternetPresent) {

                } else {
                    Toast.makeText(getApplicationContext(),
                            "Please Connect to the Internet.",Toast.LENGTH_SHORT).show();
                    }
            }
        }
        if (usersArrayList.size() > 0) {
            if (editTextUserId.getText().toString().length() > 0) {
                if (editTextPassword.getText().toString().length() > 0) {
                    String edUser = editTextUserId.getText().toString();
                    String edPass = editTextPassword.getText().toString();

                    for (int i = 0; i < usersArrayList.size(); i++) {
                        Users user = usersArrayList.get(i);
                        String userString = user.getUserName();
                        String passString = user.getPassword();

                        Log.d("User Name ", user.getUserName()
                                    + " Password  " + user.getPassword());
                        compareCredentials(userString, passString, edUser,
                                    edPass);
                    }
                    if (userFound == false) {
                        Toast.makeText(getApplicationContext(),
                            "User name or Password is wrong.",Toast.LENGTH_SHORT).show();
                    }
                } else {
                    Toast.makeText(getApplicationContext(),
                            "Please Add Password.", Toast.LENGTH_SHORT).show();
                }
            } else {
                Toast.makeText(getApplicationContext(),
                            "Please Add Username.", Toast.LENGTH_SHORT).show();
            }

        }
    }
}

private void compareCredentials(String U, String P, String edtU, String edtP) {
    if (userFound == false) {
        if (U.equals(edtU) && P.equals(edtP)) {
            userFound = true;
            Intent intent = new Intent(LoginActivity.this,
                        MainActivity.class);
            // intent.putExtra("username",
            // editTextUserId.getText().toString());
            Constants.userName = U;// user name enter
            //Toast.makeText(getApplicationContext(), Constants.userName,
            //Toast.LENGTH_SHORT).show();
            startActivity(intent);
        } else {

        }
    } else {
        return;
    }

}

@Override
public void RecievedReponse(String response) {
    // TODO Auto-generated method stub
    CategoriesParser.getUsersData(response, this);
    getUserSQlite();
}

@Override
public void RecievedError(String error) {
    // TODO Auto-generated method stub
    Toast.makeText(getApplicationContext(), error, 10).show();
}

private void getUserSQlite() {
    try {
        usersArrayList.clear();
        usersArrayList = c1.GETUSERS("testincharge");
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}
}

0 个答案:

没有答案