android - Link login activity to the main activity that can pass the user id -
how pass user id next activity using android studio? in app if user enter invalid password in login activity still go same activity valid password.. how want solve it.
this code login.php
<?php require "init.php"; $user_name = $_post["login_name"]; $user_pass = $_post["login_pass"]; $sql_query = "select name user_info user_name '$user_name' , user_pass '$user_pass';"; $result = mysqli_query($con,$sql_query); if(mysqli_num_rows($result) >0 ) { $row = mysqli_fetch_assoc($result); $name =$row["name"]; echo "success"; } else { echo "fail"; } ?>
code background.java (asynctask)
protected void onpostexecute (string result) { if (alertdialog.setmessage(result)=="success") { alertdialog.show(); intent intent = new intent(ctx, index.class); intent.setflags(intent.flag_activity_new_task); bundle int = new bundle(); int.putint("id", 1); intent.putextras(int); ctx.startactivity(intent); } }
i run using equal function not work
if(result.equals("success")) { intent intent = new intent(ctx, index.class); intent.setflags(intent.flag_activity_new_task); ctx.startactivity(intent); } else { alertdialog.setmessage(result); alertdialog.show(); }
this first time developing mobile apps , using android studio. sorry asking silly question, tq
for pass user id activity. use simple code
current activity:
intent myintent = new intent(currentactivity.this, receiveractiviity.class); myintent.putextra("userid",your_user_id_value); startactivity(myintent);
receiveractiviity:
intent mintent = getintent(); int intvalue = mintent.getintextra("userid", -1); // -1 default value
hope help
Comments
Post a Comment