Send Google maps address of a messaging app to your mobile?

Asked

Viewed 260 times

0

I am creating an app in Android Studio, and I have a problem.

The app contains Google Maps where it shows us our location, but what I’d really like to do is, by pressing a button, our location is sent by SMS to a cell phone number, it will be possible?

1 answer

0


You can use the API Smsmanager:

btnSendSMS.setOnClickListener(new View.OnClickListener() {
    public void onClick(View v) {
        enviarSMS("+551199999999", "Testando");
    }
});

...

//Enviando a mensagem

private void enviarSMS(String numero, String mensagem) {
    SmsManager sms = SmsManager.getDefault();
    sms.sendTextMessage(numero, null, mensagem, null, null);
}

Or you can build the message in the device’s standard SMS application:

btnSendSMS.setOnClickListener(new View.OnClickListener() {
    public void onClick(View v) {
        enviarSMS("+551199999999", "Testando");
    }
});

...

//Enviando a mensagem

private void enviarSMS(String numero, String mensagem) {
    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("sms:" + numero));
    intent.putExtra("sms_body", mensagem);
    startActivity(intent);
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.