Android Open Source - fieldreporter Location Receiver






From Project

Back to project page fieldreporter.

License

The source code is released under:

Apache License

If you think the Android project fieldreporter 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 com.donnemartin.android.fieldreporter;
//from  w w  w .  j a va  2  s.  com
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.location.Location;
import android.location.LocationManager;
import android.util.Log;

public class LocationReceiver extends BroadcastReceiver {

    private static final String TAG = "LocationReceiver";

    @Override
    public void onReceive(Context context, Intent intent) {
        Location loc = (Location)intent.getParcelableExtra(LocationManager.KEY_LOCATION_CHANGED);
        if (loc != null) {
            onLocationReceived(context, loc);
            return;
        }
        // if we get here, something else has happened
        if (intent.hasExtra(LocationManager.KEY_PROVIDER_ENABLED)) {
            boolean enabled = intent.getBooleanExtra(LocationManager.KEY_PROVIDER_ENABLED, false);
            onProviderEnabledChanged(enabled);
        }
    }
    
    protected void onLocationReceived(Context context, Location loc) {
        Log.d(TAG, this + " Got location from " + loc.getProvider() + ": " + loc.getLatitude() + ", " + loc.getLongitude());
    }
    
    protected void onProviderEnabledChanged(boolean enabled) {
        Log.d(TAG, "Provider " + (enabled ? "enabled" : "disabled"));
    }

}




Java Source Code List

android.UnusedStub.java
com.donnemartin.android.fieldreporter.DataLoader.java
com.donnemartin.android.fieldreporter.LastLocationLoader.java
com.donnemartin.android.fieldreporter.LocationListCursorLoader.java
com.donnemartin.android.fieldreporter.LocationReceiver.java
com.donnemartin.android.fieldreporter.ReportActivity.java
com.donnemartin.android.fieldreporter.ReportDatabaseHelper.java
com.donnemartin.android.fieldreporter.ReportFragment.java
com.donnemartin.android.fieldreporter.ReportListActivity.java
com.donnemartin.android.fieldreporter.ReportListFragment.java
com.donnemartin.android.fieldreporter.ReportLoader.java
com.donnemartin.android.fieldreporter.ReportManager.java
com.donnemartin.android.fieldreporter.ReportMapActivity.java
com.donnemartin.android.fieldreporter.ReportMapFragment.java
com.donnemartin.android.fieldreporter.Report.java
com.donnemartin.android.fieldreporter.SQLiteCursorLoader.java
com.donnemartin.android.fieldreporter.SingleFragmentActivity.java
com.donnemartin.android.fieldreporter.TrackingLocationReceiver.java