, . Ion, . .
Ion.with(getApplicationContext())
.load("http://www.example.com/abc/def/")
.setBodyParameter("identifier", "foo")
.setBodyParameter("email", "foo@foo.com")
.setBodyParameter("password", "p@ssw0rd")
.asString()
.setCallback(new FutureCallback<String>() {
@Override
public void onCompleted(Exception e, String result) {
}
});
! , AndroidManifest.xml <application>, .
<uses-permission android:name="android.permission.INTERNET" />
, onComplete ( // Result).:
try {
JSONObject json = new JSONObject(result);
String json_result = json.getString("result");
if (json_result.equalsIgnoreCase("ok")){
int customer_id = json.getInt("customer_id");
String customer_email = json.getString("customer_email");
} else {
String error = json.getString("error");
Toast.makeText(getApplicationContext(), error, Toast.LENGTH_LONG).show();
Intent to_main = new Intent(getApplicationContext(), MainActivity.class);
startActivity(to_main);
finish();
}
} catch (JSONException e){
Log.e(TAG, e.getMessage());
Toast.makeText(getApplicationContext(), "Please check your internet connection.", Toast.LENGTH_LONG).show();
}
, , , , - JSON- .