android - How to send mobile number to Send activity? -


request_viewer activity

public class request_viewer extends listactivity {     private progressdialog pdialog;     private static final string request_viewer_url = "http://192.168.43.84/taxiservice/request_view.php";     private static final string tag_posts = "posts";     private static final string tag_request_id = "request_id";     private static final string tag_customer_city = "currentcity";     private static final string tag_customer_name = "customername";     private static final string tag_customer_mobile = "customermobile";     private static final string tag_starting_location = "starting_location";     private static final string tag_distination = "destination";     private static final string tag_whendate = "whendate";     private static final string tag_whentime = "whentime";     private jsonarray crequest = null;     private arraylist<hashmap<string, string>> crequestlist;     handler mhandler;     textview textviewmobile;      @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.request_viewer);          this.mhandler = new handler();         m_runnable.run();     }     private final runnable m_runnable = new runnable()     {         public void run()          {             request_viewer.this.mhandler.postdelayed(m_runnable,200);         }     };      @override     protected void onresume() {         // todo auto-generated method stub         super.onresume();         new loadrequests().execute();     }      public void addrefresh(view v) {         new loadrequests().execute();     }     public void addyes(view v) {         intent = new intent(getapplicationcontext(),send.class);         startactivity(i);     }     public void updatejsondata() {         crequestlist = new arraylist<hashmap<string, string>>();         jsonparser jparser = new jsonparser();         jsonobject json = jparser.getjsonfromurl(request_viewer_url);         try {             crequest = json.getjsonarray(tag_posts);             (int = crequest.length()-1; > 0; i--) {                 jsonobject c = crequest.getjsonobject(i);                        string request_id = c.getstring(tag_request_id);                 string current_city = c.getstring(tag_customer_city);                 string customer_name = c.getstring(tag_customer_name);                 string customer_mobile = c.getstring(tag_customer_mobile);                 string starting_location = c.getstring(tag_starting_location);                 string distination = c.getstring(tag_distination);                 string whendate = c.getstring(tag_whendate);                 string customer_time = c.getstring(tag_whentime);                 hashmap<string, string> map = new hashmap<string, string>();                 map.put(tag_request_id, request_id);                 map.put(tag_customer_city, current_city);                 map.put(tag_customer_name, customer_name);                 map.put(tag_customer_mobile, customer_mobile);                 map.put(tag_starting_location, starting_location);                 map.put(tag_distination, distination);                 map.put(tag_whendate, whendate);                 map.put(tag_whentime, customer_time);                 crequestlist.add(map);             }          } catch (jsonexception e) {             e.printstacktrace();         }     }     private void updatelist() {         listadapter adapter = new simpleadapter(this, crequestlist,                 r.layout.single_view, new string[] { tag_request_id,tag_customer_city,tag_customer_name,tag_customer_mobile,tag_starting_location,tag_distination, tag_whendate,                 tag_whentime }, new int[] { r.id.request_id,r.id.current_city,r.id.customer_name,r.id.customer_mobile, r.id.starting_location,                 r.id.distination,r.id.whendate,r.id.customer_time });         setlistadapter(adapter);         listview lv = getlistview();         lv.setonitemclicklistener(new onitemclicklistener() {             @override             public void onitemclick(adapterview<?> parent, view view, int position, long id) {             textviewmobile=(textview)findviewbyid(r.id.customer_mobile);             final  string customermobile=textviewmobile.gettext().tostring();             intent intent = new intent(request_viewer.this, send.class);             intent.putextra("customermobile",customermobile);              startactivity(intent);             }         });     }     public class loadrequests extends asynctask<void, void, boolean> {         @override         protected void onpreexecute() {             super.onpreexecute();             pdialog = new progressdialog(request_viewer.this);             pdialog.setmessage("loading requests...");             pdialog.setindeterminate(false);             pdialog.setcancelable(true);             pdialog.show();         }         @override         protected boolean doinbackground(void... arg0) {             updatejsondata();             return null;         }         @override         protected void onpostexecute(boolean result) {             super.onpostexecute(result);             pdialog.dismiss();             updatelist();         }     } } **send activity**  package com.example.king.driverapptaxiexpress; import android.app.activity; import android.app.alertdialog; import android.os.bundle; import android.telephony.smsmanager; import android.view.view; import android.widget.button; import android.widget.edittext; import android.widget.textview; import android.widget.toast; public class send extends activity {     edittext answeryes;     textview phone;     button driversend;     @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_send);         answeryes = (edittext) findviewbyid(r.id.edityes);         phone=(textview)findviewbyid(r.id.editview1);         driversend = (button) findviewbyid(r.id.button1);          //int index = data.getintextra("songindex", 0);         phone.settext(getintent().getextras().getstring("customermobile",null));         driversend.setonclicklistener(new view.onclicklistener() {             @override             public void onclick(view v) {                 string phonenumber = ((textview)findviewbyid(r.id.editview1)).gettext().tostring();                 string yes=answeryes.gettext().tostring();                  try {                     smsmanager.getdefault().sendtextmessage(phonenumber, null,yes, null, null);                     toast.maketext(getapplicationcontext(), "sent successfully", toast.length_short).show();                 }                 catch (exception e) {                     toast.maketext(getapplicationcontext(), "sending fail", toast.length_short).show();                     alertdialog.builder alertdialogbuilder = new alertdialog.builder(send.this);                     alertdialog dialog = alertdialogbuilder.create();                     dialog.setmessage(e.getmessage());                     dialog.show();                 }             }         });     } } 

my php sctipt is

<?php $query_params=null; require("config.inc.php"); $query = "select * req_spec"; try {     $stmt   = $db->prepare($query);     $result = $stmt->execute($query_params); } catch (pdoexception $ex) {     $response["success"] = 0;     $response["message"] = "database error!";     die(json_encode($response)); }  $rows = $stmt->fetchall(); if ($rows) {     $response["success"] = 1;     $response["message"] = "available requests";     $response["posts"]   = array();     foreach ($rows $row) {         $post             = array();         $post["request_id"]  = $row["request_id"];         $post["currentcity"] = $row["currentcity"];         $post["customername"] = $row["customername"];         $post["customermobile"] = $row["customermobile"];         $post["starting_location"] = $row["starting_location"];         $post["destination"]    = $row["destination"];         $post["whendate"]  = $row["whendate"];         $post["whentime"]  = $row["whentime"];         //update our repsonse json data         array_push($response["posts"], $post);     }    // echoing json response     echo json_encode($response);  }  else {     $response["success"] = 0;     $response["message"] = "no requests available";     die(json_encode($response)); } ?>` 


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -