0

im doing an antitheft app as a part of my project.What my app mainly does is that it detects whether the sim has been changed,if it is changed i wand to get the current location and send it to a preset location.I implemented sim detection by comparing the subscriber id at the time of app installation and each boot.Now i got stuck on the following functons

1)how to get the location without using gps or internet

2)how to retrieve the location to sms and send it to the preset number

Somebody please help me .i have been stuck on this for weeks.....

Jerry
  • 1
  • 1

1 Answers1

0

1) You can try to get last know position from gps or network provider

LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
Location gpsLocation = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
Location networkLocation =  locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);

2) You can use this code

 Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("sms:" + phoneNumber));
 intent.putExtra("sms_body", message);
 startActivity(intent);

or check this answer How can I send sms messages in the BACKGROUND using Android?

Don't forget to add required permissions

Community
  • 1
  • 1
Dehimb
  • 252
  • 3
  • 15