Skip to content

Instantly share code, notes, and snippets.

@walidum
Created May 9, 2021 10:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save walidum/67b1bd63e34a2d03400b14cb2611790c to your computer and use it in GitHub Desktop.
Save walidum/67b1bd63e34a2d03400b14cb2611790c to your computer and use it in GitHub Desktop.
Android
Map<String, String> map = new HashMap<>();
map.put("phonenumber", phoneNumber);
map.put("newpassword", newpassword);
FirebaseUser mUser = FirebaseAuth.getInstance().getCurrentUser();
mUser.getIdToken(true)
.addOnCompleteListener(new OnCompleteListener<GetTokenResult>() {
public void onComplete(@NonNull Task<GetTokenResult> task) {
if (task.isSuccessful()) {
String idToken = task.getResult().getToken();
map.put("token_ak", idToken);
Call<HashMap<String, String>> call3 = apiInterface.changepasswordphone(map);
call3.enqueue(new Callback<HashMap<String, String>>() {
@Override
public void onResponse(Call<HashMap<String, String>> call, Response<HashMap<String, String>> response) {
HashMap<String, String> data = response.body();
Log.v("forgotPassword", "Response=" + data);
if (data.get(Constants.TAG_STATUS).equals("true")) {
Toast.makeText(LoginActivity.this, getResources().getString(R.string.pass_is_change), Toast.LENGTH_SHORT).show();
} else
Toast.makeText(LoginActivity.this, getResources().getString(R.string.pass_is_not_change), Toast.LENGTH_SHORT).show();
if (progressDialog.isShowing())
progressDialog.dismiss();
}
@Override
public void onFailure(Call<HashMap<String, String>> call, Throwable t) {
call.cancel();
if (progressDialog.isShowing())
progressDialog.dismiss();
}
});
} else {
// Handle error -> task.getException();
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment