Send android activity variable to php script -


i'm trying read php script url through qr code , retrieve mac of device, after that, want send mac php script android app crashing if try it.

i'm opening url in browser using intent. should write @ php side retrieve mac address , changes in android activity?

code:

protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_decoder);      mydecoderview = (qrcodereaderview) findviewbyid(r.id.qrdecoderview);     mydecoderview.setonqrcodereadlistener(this);      mytextview = (textview) findviewbyid(r.id.exampletextview);      line_image = (imageview) findviewbyid(r.id.red_line_image);      translateanimation manimation = new translateanimation(             translateanimation.absolute, 0f,             translateanimation.absolute, 0f,             translateanimation.relative_to_parent, 0f,             translateanimation.relative_to_parent, 0.5f);     manimation.setduration(1000);     manimation.setrepeatcount(-1);     manimation.setrepeatmode(animation.reverse);     manimation.setinterpolator(new linearinterpolator());     line_image.setanimation(manimation);       button button2 = (button) findviewbyid(r.id.button2);     button2.setonclicklistener(             new view.onclicklistener() {                 public void onclick(view v) {                /*string ur="http://192.168.0.105/project/rec.html";                     intent intent1=new intent("android.intent.action.view");                     if (!ur.contains("http://"))                         ur = "http://" + ur;                     intent1.setdata(uri.parse(ur));                      startactivity(intent1);// perform action on click*/                    }              });     }  // called when qr decoded // "text" : text encoded in qr // "points" : points qr control points placed  @override public void onqrcoderead(string text, pointf[] points) {      wifimanager wifimanager = (wifimanager) getsystemservice(context.wifi_service);     wifiinfo winfo = wifimanager.getconnectioninfo();     action = winfo.getmacaddress();      httpclient httpclient = new defaulthttpclient();     httppost httppost = new httppost(addr);       try {          list<namevaluepair> namevaluepairs = new arraylist<namevaluepair(1);         namevaluepairs.add(new basicnamevaluepair("action",action));          httppost.setentity(new urlencodedformentity(namevaluepairs));           responsehandler<string> responsehandler = newbasicresponsehandler();         string response = httpclient.execute(httppost, responsehandler);           string reversestring = response;       } catch (clientprotocolexception e) {       } catch (ioexception e) {         }      intent localintent = new intent("android.intent.action.view");     if (!text.contains("http://"))          text = "http://" + text;     addr=text;     localintent.setdata(uri.parse(text));      startactivity(localintent);   } 

error_reporting(0); include("db_config.php"); $response = array(); if (isset($_get['id'])) {     $id = $_get['id'];     $item = $_get['item'];      $r = mysql_query("select department_id student st_id = '$id'");     $row = mysql_fetch_array($r);     $department_id = $row[0];     $r = mysql_query("select subject_name subject subject_code ='$item'");     $row = mysql_fetch_array($r);     $subject_name = $row[0];     $result = mysql_query("insert `sis_fyp`.`student-subject` (`st_id`, `subject_code`, `status`, `grade`, `department_id`, `subject_name`) values ('$id', '$item', 'repeat', 'w', '$department_id', '$subject_name');");      if ($result>0) {         $response["success"] = 1;     } else {         $response["success"] = 0;     }     // echoing json response     echo json_encode($response); } 

just make php script above , pass url in , android like:

wwww.yoururl.com?id=$id&item=$item


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -