i developed a simple app using android 4.0.3. The problem im having is the login screen. It is logging in using android 4.0.3 version but when i install it on android 6.1 it refuses to login in. Im failing to see where the problem lies.
heres is the source code for the login screen. Its just showing an error saying check your connection settings of which that is an error message i provided
public class LoginForm extends AppCompatActivity implements View.OnClickListener {
//EditText editTextUserName,editTextPassword;
CardView cardView;
FButton btnCallAndRegister;
FButton loginButton;
FButton btnSms;
EditText edtUserName;
private ProgressDialog mProgress;
String login_url = "https://volleycrud.000webhostapp.com/churchapp/logger.php";
String gotUserName;
// ProgressDialog mProgressDialog;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.login_form);
mProgress = new ProgressDialog(LoginForm.this, R.style.MyAlertDialogStyle);
mProgress.setTitle("Processing...");
mProgress.setMessage("Logging in Please wait...");
mProgress.setCancelable(false);
mProgress.setIndeterminate(true);
loginButton = (FButton) findViewById(R.id.btnLogin);
edtUserName = (EditText) findViewById(R.id.edtName);
cardView = (CardView) findViewById(R.id.cardView);
btnCallAndRegister = (FButton)findViewById(R.id.btnRegisterCall);
btnSms = (FButton)findViewById(R.id.smsButton);
//get the data as json from the server for the branch name
android.view.animation.Animation animation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.swing_up_left);
cardView.setAnimation(animation);
btnSms.setOnClickListener(this);
btnCallAndRegister.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:0772325760"));
if (ActivityCompat.checkSelfPermission(LoginForm.this,
Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {
return;
}
startActivity(callIntent);
}
});
loginButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
if(edtUserName.getText().equals("")){
CookieBar.build(LoginForm.this)
.setTitle("Error")
.setMessage("Please enter a username")
.show();
}
else {
mProgress.show();
gotUserName = edtUserName.getText().toString();
RequestQueue queue = Volley.newRequestQueue(LoginForm.this);
StringRequest request = new StringRequest(Request.Method.POST, login_url, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
if (response.trim().equals("success")) {
mProgress.hide();
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
startActivity(intent);
finish();
} else {
CookieBar.build(LoginForm.this)
.setTitle("Error")
.setMessage("Please check your username")
.show();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
CookieBar.build(LoginForm.this)
.setTitle("Error")
.setMessage("Check Your Connection Settings")
.show();
Log.i("My error", "" + error);
}
}) {
@Override
protected Map<String, String> getParams() throws AuthFailureError {
Map<String, String> map = new HashMap<String, String>();
map.put("username", gotUserName);
return map;
}
};
queue.add(request);
}
}
});
}
@Override
public void onClick(View v) {
switch (v.getId()){
case R.id.smsButton:
AlertDialog dialogSms = new AlertDialog.Builder(LoginForm.this).create();
dialogSms.setTitle("Send Us A Message");
dialogSms.setIcon(R.drawable.uficlogo);
final LinearLayout layout = new LinearLayout(LoginForm.this);
layout.setOrientation(LinearLayout.VERTICAL);
final EditText order = new EditText(this);
order.setHintTextColor(Color.BLUE);
order.setHint("Enter your Message");
layout.addView(order);
dialogSms.setView(layout);
dialogSms.setButton(Dialog.BUTTON_POSITIVE,"Send SMS",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
String message = order.getText().toString();
if (!message.equals("")) {
sendMySms(message);
} else {
CookieBar.build(LoginForm.this)
.setTitle("Error")
.setMessage("Message Not Sent")
.show();
}
}
private void sendMySms(String message) {
// TODO Auto-generated method stub
String number = "0772 325 760".trim();
Intent intent = new Intent(getApplicationContext(),
LoginForm.class);
PendingIntent pi = PendingIntent.getActivity(
getApplicationContext(), 0, intent, 0);
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(number, null, message, pi,
null);
CookieBar.build(LoginForm.this)
.setTitle("Success")
.setMessage("Message Sent")
.show();
}
});
dialogSms.show();
break;
}
}
}