我正在网上搜索,但我找不到任何解决方案。我只是在android中创建一个简单的LOG IN来获取MYSQL中的用户数据。这个错误显示给我的日志猫
load_library(linker.cpp:759):library" libmaliinstr.so"找不到
任何人都可以帮助我谢谢
这是我的java文件
public class DisplayloginActivity extends Activity {
Button btnlogin;
EditText etusername, etpassword;
TextView tvforgot,tv;
HttpPost httppost;
StringBuffer buffer;
HttpResponse response;
HttpClient httpclient;
List<NameValuePair> nameValuePairs;
ProgressDialog pDialog = null;
SessionManager session;
public static final String MyPREF = "MyPrefs";
public static final String usernamepref = "usernamekey";
public static final String passwordpref = "passwordkey";
public static final String attenderno1 = "";
SharedPreferences sharedpreferences;
//url
private static String url_login = "http://192.168.0.102/SchoolServiceTracker/Android/Connection/a.php";
private static String url_getuser = "http://192.168.106/SchoolServiceTracker/Android/Attender/getuser.php";
//JSON node name
private static final String TAG_SUCCESS = "success";
static int success = 0;
//JSONParser
JSONParser sstParser = new JSONParser();
//String declaration
String attenderno, aname, licenseno, emailadd, plateno, authorizedroute, alatitude, alongitude, schoolname;
String getSuccessResult;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.displaylogin);
//session manager
//session = new SessionManager(getApplicationContext());
//declare var
btnlogin = (Button) findViewById(R.id.loginbtn);
etusername = (EditText) findViewById(R.id.usernameet);
etpassword = (EditText) findViewById(R.id.passwordet);
tvforgot = (TextView) findViewById(R.id.forgot);
tv = (TextView) findViewById(R.id.tv);
//forgot username/password onclick
tvforgot.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
forgotAlert();
//Toast.makeText(getApplicationContext(), "Please Contact you School Administrator", Toast.LENGTH_LONG).show();
}
});
//login button onclick
btnlogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
pDialog = ProgressDialog.show(DisplayloginActivity.this, "", "Validating user...", true);
//new Thread(new Runnable(){
// public void run() {
// loginattender();
// }
//}).start();
new loginattender().execute();
}
});
}
class loginattender extends AsyncTask<String, String, String> {
@Override
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(DisplayloginActivity.this);
pDialog.setMessage("Logging in....");
pDialog.setIndeterminate(false);
pDialog.setCancelable(true);
pDialog.show();
}
protected String doInBackground(String... args) {
String username = etusername.getText().toString();
String password = etpassword.getText().toString();
List<NameValuePair> param = new ArrayList<NameValuePair>();
param.add(new BasicNameValuePair("username", username));
param.add(new BasicNameValuePair("password", password));
JSONObject json = sstParser.makeHttpRequest(url_login, "GET", param);
Log.d("USER: ", json.toString());
success = 0;
try{
success = json.getInt(TAG_SUCCESS);
if (success == 1) {
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("username", username));
json = sstParser.makeHttpRequest(url_getuser, "GET", params);
Log.d("user details", json.toString());
Intent i = new Intent(getApplicationContext(), Mainpage.class);
startActivity(i);
}else if(success == 0) {
Intent i = new Intent(getApplicationContext(), DisplayloginActivity.class);
i.putExtra("success", 0);
i.putExtra("username", etusername.getText().toString());
finish();
startActivity(i);
}
} catch (JSONException e) {
e.printStackTrace();
}
return null;
}
protected void onPostExecute(String file_url) {
pDialog.dismiss();
}
}
/*void loginattender() {
try{
httpclient = new DefaultHttpClient();
httppost = new HttpPost("http//192.168.1.101/SchoolServiceTracker/Android/Connection/a.php");
nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("username", etusername.getText().toString().trim()));
nameValuePairs.add(new BasicNameValuePair("password", etusername.getText().toString().trim()));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
response = httpclient.execute(httppost);
ResponseHandler<String> responseHandler = new BasicResponseHandler();
final String response = httpclient.execute(httppost, responseHandler);
System.out.println("Response: " + response);
runOnUiThread(new Runnable() {
public void run() {
tv.setText("Responce from PHP : " + response);
pDialog.dismiss();
}
});
if(response.equalsIgnoreCase("User Found")){
runOnUiThread(new Runnable () {
public void run() {
Toast.makeText(DisplayloginActivity.this, "Login Success", Toast.LENGTH_SHORT).show();
//String username = etusername.getText().toString();
//String password = etpassword.getText().toString();
//session.createLoginSession(username, password);
}
});
DisplayloginActivity.this.finish();
Editor editor = sharedpreferences.edit();
String usernamelite = etusername.getText().toString();
String passwordlite = etpassword.getText().toString();
editor.putString(usernamepref, usernamelite);
editor.putString(passwordpref, passwordlite);
editor.commit();
Intent loginintent = new Intent(getApplicationContext(), Mainpage.class);
startActivity(loginintent);
} else {
showAlert();
}
}catch (Exception e) {
pDialog.dismiss();
System.out.println("Exception: "+ e.getMessage());
}
}*/
public void forgotAlert(){
DisplayloginActivity.this.runOnUiThread(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
AlertDialog.Builder builder= new AlertDialog.Builder(DisplayloginActivity.this);
builder.setTitle("Forgot Username/Passwrod");
builder.setMessage("Please Contact you School Administrator")
.setCancelable(false)
.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
}
});
AlertDialog alert = builder.create();
alert.show();
}
});
}
public void showAlert(){
DisplayloginActivity.this.runOnUiThread(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
AlertDialog.Builder builder= new AlertDialog.Builder(DisplayloginActivity.this);
builder.setTitle("Login Error");
builder.setMessage("User cannot Found")
.setCancelable(false)
.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
}
});
AlertDialog alert = builder.create();
alert.show();
}
});
}
@Override
protected void onResume() {
sharedpreferences = getSharedPreferences(MyPREF,
Context.MODE_PRIVATE);
if (sharedpreferences.contains(usernamepref));
{
if(sharedpreferences.contains(passwordpref)){
Intent i = new Intent(this, Mainpage.class);
startActivity(i);
}
}
super.onResume();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.displaylogin, menu);
return true;
}
}
答案 0 :(得分:-1)
只需使用try catch block
try {
// Write your code here
}catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Error e) {
// TODO Auto-generated catch block
e.printStackTrace();
}