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

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -