'How do i add registered username in android application to SMS?
I'm currently developing a GPS Live Tracking Android Application. So the function of the application is to send a SMS to the admin mobile number using the registered number about their Longitude and Latitude. Since it too general. I've thought of adding the registered username into the SMS so that it will show as this = (Username Longitude : 1.23434 & Latitude : 2.3434...)
SMS code:
locationListener = new LocationListener() {
@Override
public void onLocationChanged(Location location) {
try {
latLng = new LatLng(location.getLatitude(), location.getLongitude());
mMap.addMarker(new MarkerOptions().position(latLng).title("My Position"));
mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
String phoneNumber = "+601156451587";
String myLatitude = String.valueOf(location.getLatitude());
String myLongitude = String.valueOf(location.getLongitude());
String message = " Location at Latitude : " + myLatitude + " Longitude : " + myLongitude;
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(phoneNumber,null,message,null,null);
}
catch (Exception e){
e.printStackTrace();
}
}
SMS output
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|