У меня есть приложение для добавления нового идентификатора в базу данных с помощью php. Если я нажму кнопку , создайте id в моей программе, он всегда закрывает все, кроме данных, вставленных в базу данных.Android приложение закрывается после нажатия кнопки
Я не знаю, как это исправить. В моем logcat
информация отсутствует.
Это мой код:
Toolbar toolbar;
// Progress Dialog
private ProgressDialog pDialog;
JSONParser jsonParser = new JSONParser();
EditText inputusername;
EditText inputpassword;
EditText inputnamegm;
TextView registerErrorMsg;
Button createidgm;
// url to create news
private static String url_create_idgm = "http://192.168.1.111/add/create_idgm.php";
// JSON Node names
private static final String TAG_SUCCESS = "success";
private static final String TAG_ERROR = "error";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_create_idgm);
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
TypedValue typedValueColorPrimaryDark = new TypedValue();
CreateIDGM.this.getTheme().resolveAttribute(R.attr.colorPrimary, typedValueColorPrimaryDark, true);
final int colorPrimaryDark = typedValueColorPrimaryDark.data;
if (Build.VERSION.SDK_INT >= 21) {
getWindow().setStatusBarColor(colorPrimaryDark);
}
// Edit Text
inputusername = (EditText) findViewById(R.id.inputusername);
inputpassword = (EditText) findViewById(R.id.inputpassword);
inputnamegm = (EditText) findViewById(R.id.inputname);
registerErrorMsg = (TextView) findViewById(R.id.error);
// Create button
createidgm = (Button) findViewById(R.id.btnCreate);
// button click event
createidgm.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// creating new product in background thread
new NetCheck().execute();
}
});
}
/**
* Background Async Task to Create new product
* */
class NetCheck extends AsyncTask<String, String, String> {
/**
* Before starting background thread Show Progress Dialog
* */
@Override
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(CreateIDGM.this);
pDialog.setMessage("Creating ID Game Master..");
pDialog.setIndeterminate(false);
pDialog.setCancelable(true);
pDialog.show();
}
/**
* Creating product
* */
protected String doInBackground(String... args) {
String name = inputusername.getText().toString();
String version = inputpassword.getText().toString();
String description = inputnamegm.getText().toString();
// Building Parameters
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("username", name));
params.add(new BasicNameValuePair("password", version));
params.add(new BasicNameValuePair("name", description));
// getting JSON Object
// Note that create product url accepts POST method
JSONObject json = jsonParser.makeHttpRequest(url_create_idgm,
"POST", params);
// check log cat fro response
Log.d("Create Response", json.toString());
// check for success tag
try {
int success = json.getInt(TAG_SUCCESS);
if (success == 1) {
// successfully created product
//Toast.makeText(CreateIDGM.this, "Success Create ID Game Master ", Toast.LENGTH_SHORT).show();
Intent i = new Intent(getApplicationContext(), ListTopGM.class);
startActivity(i);
// closing this screen
finish();
} else {
// failed to create product
}
} catch (JSONException e) {
e.printStackTrace();
}
return null;
}
protected void onPostExecute(String file_url) {
// dismiss the dialog once done
pDialog.dismiss();
}
}
Может кто-то помочь мне решить эту проблему?