Hi there,
I am new in android development and have been struggling for over a month now to insert data to a remote database. I am using a JSON RestAPI and testing the app using Sumsang Trend Plus device. I have manually inserted some data into the table and used the app to login, and it is working. Hence I concluded that the app can connect to the the database. However it is not inserting from the app no matter what I have tried. Did a lot of search but nothing seems to help. Below is the piece of code and some lines from the Logcat:
protected class AsyncCreateUser extends AsyncTask<useraccounttable,> {
@Override
protected Void doInBackground(UserAccountTable... params){
RestAPI api = new RestAPI();
try{
api.CreateNewAccount(params[0].getUserName(), params[1].getPassword(), params[2].getQuestion(), params[3].getAnswer());
}catch (Exception e){
Log.d("AsyncCreateUser", e.getMessage());
}
return null;
}
@Override
protected void onPreExecute(){
super.onPreExecute();
Toast.makeText(context, "Please wait...", Toast.LENGTH_SHORT).show();
}
@Override
protected void onPostExecute(Void result){
Intent ro = new Intent(getApplicationContext(), Reg_Owner.class);
// Intent ro = new Intent(Settings.ACTION_ADD_ACCOUNT);
// ro.setFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
// ro.putExtra(Settings.EXTRA_AUTHORITIES, new String[]{"hlelotech.muniservsa.Reg_Owner"});
ro.putExtra("username",username);
startActivity(ro);
}
}
Here is my RestAPI sample:
public JSONObject CreateNewAccount(String userName,String password,String question,String answer) throws Exception {
JSONObject result = null;
JSONObject o = new JSONObject();
JSONObject p = new JSONObject();
o.put("interface","RestAPI");
o.put("method", "CreateNewAccount");
p.put("userName",mapObject(userName));
p.put("password",mapObject(password));
p.put("question",mapObject(question));
p.put("answer",mapObject(answer));
o.put("parameters", p);
String s = o.toString();
String r = load(s);
result = new JSONObject(r);
return result;
}
And few lines from the Logcat:
11-15 21:50:04.838 26959-26959/hlelotech.muniservsa E/ViewRootImpl﹕ sendUserActionEvent() mView == null
11-15 21:50:56.018 26959-26959/hlelotech.muniservsa E/ViewRootImpl﹕ sendUserActionEvent() mView == null
11-15 21:51:47.418 26959-26959/hlelotech.muniservsa E/ViewRootImpl﹕ sendUserActionEvent() mView == null
11-15 21:51:49.420 26959-26959/hlelotech.muniservsa E/ViewRootImpl﹕ sendUserActionEvent() mView == null
11-15 21:51:52.293 26959-26959/hlelotech.muniservsa E/ViewRootImpl﹕ sendUserActionEvent() mView == null
11-15 21:51:54.155 26959-26959/hlelotech.muniservsa E/ViewRootImpl﹕ sendUserActionEvent() mView == null
11-15 21:52:26.206 26959-26959/hlelotech.muniservsa E/ViewRootImpl﹕ sendUserActionEvent() mView == null
11-15 21:52:28.188 26959-26959/hlelotech.muniservsa E/ViewRootImpl﹕ sendUserActionEvent() mView == null
11-15 21:58:35.576 31847-31860/hlelotech.muniservsa I/MotionRecognitionManager﹕ .unregisterListener : / listener count = 0->0,
11-15 22:03:04.198 31847-31847/hlelotech.muniservsa D/WritingBuddyImpl﹕ getCurrentWritingBuddyView()
11-15 22:03:04.219 31847-31847/hlelotech.muniservsa W/IInputConnectionWrapper﹕ getSelectedText on inactive InputConnection
11-15 22:03:04.229 31847-31847/hlelotech.muniservsa W/IInputConnectionWrapper﹕ getTextBeforeCursor on inactive InputConnection
11-15 22:03:04.229 31847-31847/hlelotech.muniservsa W/IInputConnectionWrapper﹕ getTextAfterCursor on inactive InputConnection
Please help....