java - Sending Location with SMS Message Issue? -


quick question, i've got class setup , sms messages send , i've got no errors.i trying send location part of sms message google maps link. issue messages sending location link not going through? file has no errors , messaging works.

any ideas? i've included "access fine location" in manifest file.

class:

button btnsendsms; edittext txtphoneno; edittext txtmessage; string message;  /** called when activity first created. */ @override public void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_send_sms);     btnsendsms = (button) findviewbyid(r.id.btnsendsms);     txtphoneno = (edittext) findviewbyid(r.id.txtphoneno);     txtmessage = (edittext) findviewbyid(r.id.txtmessage);       btnsendsms.setonclicklistener(new view.onclicklistener()     {         public void onclick(view v)         {             string phoneno = txtphoneno.gettext().tostring();             string message = txtmessage.gettext().tostring();             displaylocation();              if (phoneno.length()>0 && message.length()>0)                 sendsms(phoneno, message);             else                 toast.maketext(getbasecontext(),                         "please enter both phone number , message.",                         toast.length_short).show();         }     }); }       private void displaylocation(){         locationmanager locationmanager = (locationmanager)getsystemservice(context.location_service);         locationmanager.requestlocationupdates(locationmanager.gps_provider, 2000, 10, new locationlistener(){             @override             public void onstatuschanged(string s, int i, bundle bundle) {}             @override             public void onproviderenabled(string s) {}             @override             public void onproviderdisabled(string s) {}             @override             public void onlocationchanged(final location location) {}         });         location mylocation = locationmanager.getlastknownlocation(locationmanager.passive_provider);         double longitude = mylocation.getlongitude();         double latitude = mylocation.getlatitude();         message+="https://www.google.co.id/maps/@"+latitude+","+longitude; }      //---sends sms message device--- private void sendsms(string phonenumber, string message) {      pendingintent pi = pendingintent.getactivity(this, 0,             new intent(this, home.class), 0);         smsmanager sms = smsmanager.getdefault();         sms.sendtextmessage(phonenumber, null, message, pi, null);       string sent = "sms_sent";     string delivered = "sms_delivered";      pendingintent sentpi = pendingintent.getbroadcast(this, 0,             new intent(sent), 0);      pendingintent deliveredpi = pendingintent.getbroadcast(this, 0,             new intent(delivered), 0);      //---when sms has been sent---     registerreceiver(new broadcastreceiver(){         @override         public void onreceive(context arg0, intent arg1) {             switch (getresultcode())             {                 case activity.result_ok:                     toast.maketext(getbasecontext(), "sms sent",                             toast.length_short).show();                     break;                 case android.telephony.gsm.smsmanager.result_error_generic_failure:                     toast.maketext(getbasecontext(), "generic failure",                             toast.length_short).show();                     break;                 case android.telephony.gsm.smsmanager.result_error_no_service:                     toast.maketext(getbasecontext(), "no service",                             toast.length_short).show();                     break;                 case android.telephony.gsm.smsmanager.result_error_null_pdu:                     toast.maketext(getbasecontext(), "null pdu",                             toast.length_short).show();                     break;                 case android.telephony.gsm.smsmanager.result_error_radio_off:                     toast.maketext(getbasecontext(), "radio off",                             toast.length_short).show();                     break;             }         }     }, new intentfilter(sent));      //---when sms has been delivered---     registerreceiver(new broadcastreceiver(){         @override         public void onreceive(context arg0, intent arg1) {             switch (getresultcode())             {                 case activity.result_ok:                     toast.maketext(getbasecontext(), "sms delivered",                             toast.length_short).show();                     break;                 case activity.result_canceled:                     toast.maketext(getbasecontext(), "sms not delivered",                             toast.length_short).show();                     break;             }         }     }, new intentfilter(delivered));      android.telephony.gsm.smsmanager smms = android.telephony.gsm.smsmanager.getdefault();     smms.sendtextmessage(phonenumber, null, message, sentpi, deliveredpi); } 

the message variable set in displaylocation() member variable of activity (declared @ top of code). when do:

string message = txtmessage.gettext().tostring(); displaylocation(); 

that local variable message not modified.

what can return string displaylocation , add message:

private string displaylocation() {     //...     return "https://www.google.co.id/maps/@"+latitude+","+longitude; }  string message = txtmessage.gettext().tostring() + displaylocation(); if (phoneno.length()>0 && message.length()>0) //... 

and believe should remove message class member variable if aren't using anywhere else.


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

order - Notification for user in user account opencart -