Search code examples
javaandroidgeolocationsms

How do I send a SMS text message in the hidden background with current location data when the activity screen first loads on Android Studio?


I need to make an activity send a text message when it first loads on Android Studio. It's for a mobile safety app that automatically sends your location data to the police via SMS when the app first loads.

I'm trying the onStart method.

@Override
protected void onStart()
{   

super.onStart();
}

How can I do it or is there a better way?


Solution

  • You cannot send a text message without getting user permission and the same applies for assessing the location

    Assuming that you had taken permission from USER and location is on

    for sending the message here

    and for accessing location on background here and here