Android Open Source - lost-phone-tracker-app Sms Location Reporter






From Project

Back to project page lost-phone-tracker-app.

License

The source code is released under:

MIT License

If you think the Android project lost-phone-tracker-app listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package at.fhj.ase13.mobcomp2.phonetracker;
// w w w  .ja  v  a  2  s  . c om
import android.content.Context;
import android.location.Location;
import android.location.LocationManager;
import android.telephony.SmsManager;

public class SmsLocationReporter {

    private Context context;

    private String receiver;

    public SmsLocationReporter(Context context, String receiver) {
        this.context = context;
        this.receiver = receiver;
    }

    public void report() {
        LocationManager locationManager = (LocationManager) context.getSystemService(
                Context.LOCATION_SERVICE);

        String usedProvider = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)
                ? LocationManager.GPS_PROVIDER : LocationManager.NETWORK_PROVIDER;
        Location location = locationManager.getLastKnownLocation(usedProvider);

        if (location == null) {
            return;
        }

        SmsManager smsManager = SmsManager.getDefault();
        smsManager.sendTextMessage(receiver, null, context.getString(R.string.report_text,
                location.getLatitude(), location.getLongitude()), null, null);
    }
}




Java Source Code List

at.fhj.ase13.mobcomp2.phonetracker.BootReceiver.java
at.fhj.ase13.mobcomp2.phonetracker.GpsToggler.java
at.fhj.ase13.mobcomp2.phonetracker.LogAlarmReceiver.java
at.fhj.ase13.mobcomp2.phonetracker.MainActivity.java
at.fhj.ase13.mobcomp2.phonetracker.PreferenceManager.java
at.fhj.ase13.mobcomp2.phonetracker.SmsBroadcastReceiver.java
at.fhj.ase13.mobcomp2.phonetracker.SmsLocationReporter.java