RestFul API App Android -
i'm creating login in app android. have pass credentials access , compare them mysql database loaded in phpmyadmin. created api log:
route::post('/login', 'apicontroller@login');
the next step connect app , make communicate url. how connect? found various codes android studio tells me use deprecated.
i have piece of code. make sure that, in else, if email , password fields filled in, app communicates api doing login. can please me? place code written far.
public class mainactivity extends actionbaractivity { button b1, errore; edittext ed1,ed2; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.login); b1 = (button)findviewbyid(r.id.login); ed1 = (edittext)findviewbyid(r.id.email); ed2 = (edittext)findviewbyid(r.id.password); errore = (button)findviewbyid(r.id.errore); errore.setvisibility(view.invisible); b1.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { if((ed1.length() == 0) && (ed2.length() == 0)) { errore.setvisibility(view.visible); } else { //logn api } } }); } }
use asynctask send authentication post request username , password in message body.on server side, compare credential database , send login success/failure flag response. handle response accordingly in response.
Comments
Post a Comment