Example usage for android.location LocationManager NETWORK_PROVIDER

List of usage examples for android.location LocationManager NETWORK_PROVIDER

Introduction

In this page you can find the example usage for android.location LocationManager NETWORK_PROVIDER.

Prototype

String NETWORK_PROVIDER

To view the source code for android.location LocationManager NETWORK_PROVIDER.

Click Source Link

Document

Name of the network location provider.

Usage

From source file:com.microsoft.band.sdksample.SensorsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_sensors, container, false);

    senSensorManager1 = (SensorManager) getActivity().getSystemService(Context.SENSOR_SERVICE);
    senSensorManager2 = (SensorManager) getActivity().getSystemService(Context.SENSOR_SERVICE);

    senGyroscope = senSensorManager1.getDefaultSensor(Sensor.TYPE_GYROSCOPE);
    senSensorManager1.registerListener(this, senGyroscope, SensorManager.SENSOR_DELAY_NORMAL);

    senAccelerometer = senSensorManager2.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
    senSensorManager2.registerListener(this, senAccelerometer, SensorManager.SENSOR_DELAY_NORMAL);

    mTableAcc = (TableLayout) rootView.findViewById(R.id.tableAcc);
    mTableAcc.setVisibility(View.GONE);

    mTextAccX = (TextView) rootView.findViewById(R.id.textAccX);
    mTextAccY = (TextView) rootView.findViewById(R.id.textAccY);
    mTextAccZ = (TextView) rootView.findViewById(R.id.textAccZ);
    mTextAngX = (TextView) rootView.findViewById(R.id.textPAngX);
    mTextAngY = (TextView) rootView.findViewById(R.id.textPAngY);
    mTextAngZ = (TextView) rootView.findViewById(R.id.textPAngZ);

    mTextLong = (TextView) rootView.findViewById(R.id.textLong);
    mTextLat = (TextView) rootView.findViewById(R.id.textLat);

    mTextTime = (TextView) rootView.findViewById(R.id.textTime);

    temp_list = new double[14];

    c = 0;// www.j  av  a2 s . c  om
    // Acquire a reference to the system Location Manager
    LocationManager locationManager = (LocationManager) getActivity()
            .getSystemService(Context.LOCATION_SERVICE);

    // Define a listener that responds to location updates
    LocationListener locationListener = new LocationListener() {
        public void onLocationChanged(Location location) {
            // Called when a new location is found by the network location provider.
            temp_list[12] = location.getLongitude();
            temp_list[13] = location.getLatitude();
            mTextLong.setText(Double.toString(temp_list[12]));
            mTextLat.setText(Double.toString(temp_list[13]));
        }

        public void onStatusChanged(String provider, int status, Bundle extras) {
        }

        public void onProviderEnabled(String provider) {
        }

        public void onProviderDisabled(String provider) {
        }
    };

    // Register the listener with the Location Manager to receive location updates
    locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener);

    runnable.run();

    //
    // Gyro setup
    //
    mTableGyro = (TableLayout) rootView.findViewById(R.id.tableGyro);
    mTableGyro.setVisibility(View.GONE);

    mTextGyroAccX = (TextView) rootView.findViewById(R.id.textGyroAccX);
    mTextGyroAccY = (TextView) rootView.findViewById(R.id.textGyroAccY);
    mTextGyroAccZ = (TextView) rootView.findViewById(R.id.textGyroAccZ);
    mTextGyroAngX = (TextView) rootView.findViewById(R.id.textAngX);
    mTextGyroAngY = (TextView) rootView.findViewById(R.id.textAngY);
    mTextGyroAngZ = (TextView) rootView.findViewById(R.id.textAngZ);

    //
    // Contact setup
    //
    mTableContact = (TableLayout) rootView.findViewById(R.id.tableContact);
    mTableContact.setVisibility(View.GONE);
    mTextContact = (TextView) rootView.findViewById(R.id.textContact);

    turnOnSensors();

    return rootView;
}

From source file:com.uproot.trackme.LocationActivity.java

private void setup() {
    Location gpsLocation = null;//from w w w .j av  a 2  s .c om
    Location networkLocation = null;
    mLocationManager.removeUpdates(listener);
    mLatLng.setText(R.string.unknown);
    mAddress.setText(R.string.unknown);
    // Get fine location updates only.
    if (mUseFine) {
        // Request updates from just the fine (gps) provider.
        gpsLocation = requestUpdatesFromProvider(LocationManager.GPS_PROVIDER, R.string.not_support_gps);
        // Update the UI immediately if a location is obtained.
        if (gpsLocation != null)
            updateUILocation(gpsLocation);
    } else if (mUseBoth) {
        // Get coarse and fine location updates.
        // Request updates from both fine (gps) and coarse (network)
        // providers.
        gpsLocation = requestUpdatesFromProvider(LocationManager.GPS_PROVIDER, R.string.not_support_gps);
        networkLocation = requestUpdatesFromProvider(LocationManager.NETWORK_PROVIDER,
                R.string.not_support_network);

        // If both providers return last known locations, compare the two
        // and use the better
        // one to update the UI. If only one provider returns a location,
        // use it.
        if (gpsLocation != null && networkLocation != null) {
            updateUILocation(getBetterLocation(gpsLocation, networkLocation));
        } else if (gpsLocation != null) {
            updateUILocation(gpsLocation);
        } else if (networkLocation != null) {
            updateUILocation(networkLocation);
        }
    }
}

From source file:vit.riviera.LocationActivity.java

private void setup() {
    Location gpsLocation = null;//from   w ww  .j  ava 2s . c  o m
    Location networkLocation = null;
    mLocationManager.removeUpdates(listener);
    mLatLng.setText(R.string.unknown);
    mAddress.setText(R.string.unknown);
    // Get fine location updates only.
    if (mUseFine) {
        // mFineProviderButton.setBackgroundResource(R.drawable.button_active);
        //mBothProviderButton.setBackgroundResource(R.drawable.button_inactive);
        // Request updates from just the fine (gps) provider.
        gpsLocation = requestUpdatesFromProvider(LocationManager.GPS_PROVIDER, R.string.not_support_gps);
        // Update the UI immediately if a location is obtained.
        if (gpsLocation != null)
            updateUILocation(gpsLocation);
    } else if (mUseBoth) {
        // Get coarse and fine location updates.
        // mFineProviderButton.setBackgroundResource(R.drawable.button_inactive);
        //mBothProviderButton.setBackgroundResource(R.drawable.button_active);
        // Request updates from both fine (gps) and coarse (network) providers.
        gpsLocation = requestUpdatesFromProvider(LocationManager.GPS_PROVIDER, R.string.not_support_gps);
        networkLocation = requestUpdatesFromProvider(LocationManager.NETWORK_PROVIDER,
                R.string.not_support_network);

        // If both providers return last known locations, compare the two and use the better
        // one to update the UI.  If only one provider returns a location, use it.
        if (gpsLocation != null && networkLocation != null) {
            updateUILocation(getBetterLocation(gpsLocation, networkLocation));
        } else if (gpsLocation != null) {
            updateUILocation(gpsLocation);
        } else if (networkLocation != null) {
            updateUILocation(networkLocation);
        }
    }
}

From source file:org.hfoss.posit.android.api.fragment.FindFragment.java

/**
 * This may be invoked by a FindActivity subclass, which may or may not have
 * latitude and longitude fields./*from   w ww . java 2 s .c  o m*/
 */
@Override
public void onActivityCreated(Bundle savedInstanceState) {

    super.onActivityCreated(savedInstanceState);

    // Sets listeners for various UI elements
    initializeListeners();

    mAddFindMenuPlugins = FindPluginManager.getFunctionPlugins(FindPluginManager.ADD_FIND_MENU_EXTENSION);

    setHasOptionsMenu(true);

    // Initialize all UI elements for later uses
    mNameET = (EditText) getView().findViewById(R.id.nameEditText);
    mDescriptionET = (EditText) getView().findViewById(R.id.descriptionEditText);
    mGuidTV = (TextView) getView().findViewById(R.id.guidValueTextView);
    mGuidRealTV = (TextView) getView().findViewById(R.id.guidRealValueTextView);
    mTimeTV = (TextView) getView().findViewById(R.id.timeValueTextView);
    mLatTV = (TextView) getView().findViewById(R.id.latitudeTextView);
    mLatitudeTV = (TextView) getView().findViewById(R.id.latitudeValueTextView);
    mLongTV = (TextView) getView().findViewById(R.id.longitudeTextView);
    mLongitudeTV = (TextView) getView().findViewById(R.id.longitudeValueTextView);
    mAdhocTV = (TextView) getView().findViewById(R.id.isAdhocTextView);

    // Check if settings allow Geotagging
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
    mGeoTagEnabled = prefs.getBoolean("geotagKey", true);

    // If enabled, get location manager and provider
    if (mGeoTagEnabled) {
        mLocationManager = (LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE);
    }

    // Set the content of UI elements, either auto-generated or retrieved
    // from a Find
    Bundle extras = getArguments();

    if (extras != null && !(extras.size() == 1 && extras.containsKey("ACTION"))) {
        // Existing Find
        if (getAction().equals(Intent.ACTION_EDIT)) {
            int id = extras.getInt(Find.ORM_ID);
            Log.i(TAG, "ORM_id = " + id);
            //            Find find = getHelper().getFindById(id);
            mFind = getHelper().getFindById(id);
            Log.i(TAG, "Updating: " + mFind);
            displayContentInView(mFind);
        } else

        // Bundled Find (from SMS)
        if (getAction().equals(Intent.ACTION_INSERT_OR_EDIT)) {
            // Pull a Bundle corresponding to a Find from the Intent and put
            // that in the view
            Bundle findBundle = extras.getBundle("findbundle");
            //Find find;
            try {
                FindPlugin plugin = FindPluginManager.mFindPlugin;
                if (plugin == null) {
                    Log.e(TAG, "Could not retrieve Find Plugin.");
                    Toast.makeText(getActivity(), "A fatal error occurred while trying to start FindActivity",
                            Toast.LENGTH_LONG).show();
                    getActivity().finish();
                    return;
                }
                mFind = plugin.getmFindClass().newInstance();
            } catch (IllegalAccessException e) {
                Toast.makeText(getActivity(), "A fatal error occurred while trying to start FindActivity",
                        Toast.LENGTH_LONG).show();
                getActivity().finish();
                return;
            } catch (java.lang.InstantiationException e) {
                Toast.makeText(getActivity(), "A fatal error occurred while trying to start FindActivity",
                        Toast.LENGTH_LONG).show();
                getActivity().finish();
                return;
            }
            mFind.updateObject(findBundle);
            displayContentInView(mFind);
        } else
        // CSV Find   
        if (getAction().equals(CsvListFindsFragment.ACTION_CSV_FINDS)) {

        }
        // New Find
    } else {
        Log.i("TAG", "new find");
        // Set real GUID
        if (mGuidRealTV != null)
            mGuidRealTV.setText(UUID.randomUUID().toString());
        // Set displayed GUID
        if (mGuidTV != null)
            mGuidTV.setText(mGuidRealTV.getText().toString().substring(0, 8) + "...");
        // Set Time
        if (mTimeTV != null) {
            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
            Date date = new Date();
            mTimeTV.setText(dateFormat.format(date));
        }

        if (mGeoTagEnabled) {
            // Set Longitude and Latitude
            mLocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 60000, 0, this);
            mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 60000, 0, this);

            Location netLocation = mLocationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
            Location gpsLocation = mLocationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);

            if (gpsLocation != null) {
                mCurrentLocation = gpsLocation;
            } else {
                mCurrentLocation = netLocation;
            }

            if (mCurrentLocation == null) {
                Log.i(TAG, "Location issue, mCurrentLocation = " + mCurrentLocation);
                if (mLongitudeTV != null)
                    mLongitudeTV.setText("0.0");
                if (mLatitudeTV != null)
                    mLatitudeTV.setText("0.0");
                // Toast.makeText(this, "Unable to retrieve GPS info." +
                // " Please make sure your Data or Wi-Fi is enabled.",
                // Toast.LENGTH_SHORT).show();
                // Log.i(TAG,
                // "Cannot request location updates; Data or Wifi might not be enabled.");
            } else {
                if (mLongitudeTV != null)
                    mLongitudeTV.setText(String.valueOf(mCurrentLocation.getLongitude()));
                if (mLatitudeTV != null)
                    mLatitudeTV.setText(String.valueOf(mCurrentLocation.getLatitude()));
            }
        } else {
            if (mLongitudeTV != null && mLongTV != null) {
                mLongitudeTV.setVisibility(TextView.INVISIBLE);
                mLongTV.setVisibility(TextView.INVISIBLE);
            }
            if (mLatitudeTV != null && mLatTV != null) {
                mLatitudeTV.setVisibility(TextView.INVISIBLE);
                mLatTV.setVisibility(TextView.INVISIBLE);
            }
        }
    }
}

From source file:org.deviceconnect.android.deviceplugin.host.profile.HostGeolocationProfile.java

/**
 * ????.//  w  ww. ja v a  2  s .  c  om
 * @return ??
 */
private LocationManager getLocationManager(final Intent response) {
    if (mLocationManager == null) {
        mLocationManager = (LocationManager) getContext().getSystemService(Context.LOCATION_SERVICE);
    }
    // GPS??.
    if (!mLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)
            && !mLocationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) {
        Intent intent = new Intent(getContext(), GeolocationAlertDialogActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
        Bundle bundle = new Bundle();
        bundle.putParcelable("response", response);
        intent.putExtra("Intent", bundle);
        getContext().startActivity(intent);
    }
    return mLocationManager;
}

From source file:com.example.administrator.myapplication2._5_Group._5_Group.RightFragment.java

/**
 *   ??  ? /*from w ww .j  av  a 2  s  .co  m*/
 */
private void startLocationService() {
    //  ? ? 
    manager = (LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE);

    //   ?   ? ?
    gpsListener = new GPSListener();
    long minTime = 5000;//GPS    - 20  
    float minDistance = 1;//?? (10m)

    // GPS   
    manager.requestLocationUpdates(LocationManager.GPS_PROVIDER, minTime, minDistance, gpsListener);

    // ?   
    manager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, minTime, minDistance, gpsListener);

}

From source file:org.odk.collect.android.activities.GeoShapeGoogleMapActivity.java

@Override
protected void onResume() {
    super.onResume();
    mHelper.setBasemap();/*  ww  w .ja v  a2s.  c  om*/
    List<String> providers = mLocationManager.getProviders(true);

    for (String provider : providers) {
        if (provider.equalsIgnoreCase(LocationManager.GPS_PROVIDER)) {
            mGPSOn = true;
            curLocation = mLocationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
            mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);
            //                gps_button.setEnabled(true);
        }
        if (provider.equalsIgnoreCase(LocationManager.NETWORK_PROVIDER)) {
            mNetworkOn = true;
            curLocation = mLocationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
            mLocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, this);
            //                gps_button.setEnabled(true);
        }
    }

    if (mGPSOn) {
        //            mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);
        gps_button.setEnabled(true);
    }
    if (mNetworkOn) {
        //            mLocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, this);
        gps_button.setEnabled(true);
    }

}

From source file:com.kaiserdev.android.clima.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    firstTime = getPreferences(MODE_PRIVATE).getBoolean(FIRST_TIME_SETUP, true);

    //create the adapter for the views
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);
    new StatCounter().execute();

    lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    Location l = lm.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
    if (l != null) {
        curr_latitude = (float) l.getLatitude();
        curr_longitude = (float) l.getLongitude();
    }/*ww w. ja v a  2 s.c o m*/
    lm.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locList);
    mainAct = this;

}

From source file:com.jbsoft.farmtotable.FarmToTableActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    progress = new ProgressDialog(this);
    super.onCreate(savedInstanceState);

    if (readyToGo()) {
        setContentView(R.layout.activity_main);

        SupportMapFragment mapFrag = (SupportMapFragment) getSupportFragmentManager()
                .findFragmentById(R.id.map);

        initListNav();/*w w  w  .j  av a 2 s  .c o  m*/

        getSupportActionBar().setHomeButtonEnabled(true);
        sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
        getPreferences(sharedPrefs);

        sharedPrefs.registerOnSharedPreferenceChangeListener(listener);

        map = mapFrag.getMap();
        locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
        // Getting GPS status
        boolean isNETWORKEnabled = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
        boolean isGPSEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
        // If GPS enabled, get latitude/longitude using GPS Services

        if (isGPSEnabled) {
            locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, MIN_TIME_BW_UPDATES,
                    MIN_DISTANCE_CHANGE_FOR_UPDATES, gpsLocationListener);
            Log.d("GPS Enabled", "GPS Enabled");
            if (locationManager != null) {
                location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
                if (location != null) {
                    latitude = location.getLatitude();
                    longitude = location.getLongitude();
                }
            }
        }

        if (savedInstanceState == null) {

            CameraUpdate center = CameraUpdateFactory.newLatLng(new LatLng(latitude, longitude));
            map.moveCamera(center);
        }

        if (NOFM) {
            //Reverse geocoder to zipcode
            getZipFromLocation(location, this);

            //start progress box going
            //Call api to retrieve Farmers Market from the UDSA site 
            usdaurl = usdaurl + zipcode;
        } else {
            nozip = true;
        }
        //start progress box going
        progress.setMessage("Getting Farmers Markets and Other Organic Options in your area:)");
        progress.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        progress.setIndeterminate(true);
        progress.show();
        gplaceurl = placeurl_save;
        placeurl_save = gplaceurl;
        if (NOVR) {
            gplaceurl = gplaceurl + queryvegan;
        }

        if (NOOR) {
            gplaceurl = placeurl_save;
            gplaceurl = gplaceurl + queryvegetarian;
        }

        if (NOFS) {
            gplaceurl = placeurl_save;
            gplaceurl = gplaceurl + queryfarms;
        }

        if ((NOVR) && (NOOR)) {
            gplaceurl = placeurl_save;
            gplaceurl = gplaceurl + queryvegan + "&" + queryvegetarian;
        }

        if ((NOVR) && (NOFS)) {
            gplaceurl = placeurl_save;
            gplaceurl = gplaceurl + queryvegan + "&" + queryfarms;
        }

        if ((NOOR) && (NOFS)) {
            gplaceurl = placeurl_save;
            gplaceurl = gplaceurl + queryvegetarian + "&" + queryfarms;
        }

        if ((NOVR) && (NOOR) && (NOFS)) {
            gplaceurl = placeurl_save;
            gplaceurl = gplaceurl + queryvegan + "&" + queryvegetarian + "&" + queryfarms;
        }

        //The Google Places API Text Search Service 
        gplaceurl = gplaceurl + "&location=" + latitude + "," + longitude
                + "&radius=10&key=AIzaSyA_fzl-7ZkF4EINWhuQ0bcXp3zkdAXZc5o";
        //Call Asynch process Api 

        new restAPICall().execute(usdaurl, gplaceurl);
    }

    map.setInfoWindowAdapter(new CustomToast(this, null));
    // map.setOnInfoWindowClickListener((OnInfoWindowClickListener) 
    map.setMyLocationEnabled(true);
    CameraUpdate zoom = CameraUpdateFactory.zoomTo(12);
    map.animateCamera(zoom);
}

From source file:org.openpilot_nonag.androidgcs.fragments.Map.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    //disable the screen from turning off
    Log.d(TAG, "*** onCreateView");

    this.getActivity().getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    // inflate and return the layout
    View v = inflater.inflate(R.layout.map_fragment, container, false);

    //      final Button buttonApply = (Button) v.findViewById(R.id.applyBtn);
    //      buttonApply.setOnClickListener(new View.OnClickListener() {
    //            public void onClick(View v) {
    //               updateObject(homeLocationObject.getObjID(),homeLocationObject.getInstID());
    //            }
    //        });
    //      buttonApply.setEnabled(false);
    //      /*from   w  w w.java2s.  c  o m*/
    //      final Button buttonSave = (Button) v.findViewById(R.id.saveBtn);
    //      buttonSave.setOnClickListener(new View.OnClickListener() {
    //            public void onClick(View v) {
    //               saveObject(homeLocationObject);
    //            }
    //        });
    //      buttonSave.setEnabled(false);

    mapView = (MapView) v.findViewById(R.id.map_view_fragment);
    mapView.onCreate(savedInstanceState);

    // get map type from preferences
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());

    int map_type = Integer.decode(prefs.getString("map_type", "1"));

    // Needs to call MapsInitializer before doing any CameraUpdateFactory
    // calls
    MapsInitializer.initialize(getActivity());

    // something wrong *here* (only on versions with out Google Play
    // Services) need to check instead of crashing.
    // should take care of this
    int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getActivity());

    if (status == ConnectionResult.SUCCESS) {

        // Gets to GoogleMap from the MapView and does initialization stuff
        mMap = mapView.getMap();
        mMap.getUiSettings().setMyLocationButtonEnabled(true);
        mMap.setIndoorEnabled(true);
        mMap.setMyLocationEnabled(true);
        mMap.setOnMyLocationChangeListener(this);

        switch (map_type) {
        case 0:
            mMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
            mMap.getUiSettings().setIndoorLevelPickerEnabled(true);

            break;
        case 1:
            mMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
            mMap.getUiSettings().setIndoorLevelPickerEnabled(true);
            break;
        case 2:
            mMap.setMapType(GoogleMap.MAP_TYPE_TERRAIN);
            break;
        case 3:
            mMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);
            break;
        }

        UAVpathLine = mMap.addPolyline(new PolylineOptions().width(5).color(Color.WHITE));
        UAVpathLine.setPoints(UAVpathPoints);
        NEDUAVpathLine = mMap.addPolyline(new PolylineOptions().width(5).color(Color.RED));
        NEDUAVpathLine.setPoints(NEDUAVpathPoints);
        TabletpathLine = mMap.addPolyline(new PolylineOptions().width(5).color(Color.BLUE));
        TabletpathLine.setPoints(TabletpathPoints);

        registerForContextMenu(mapView);
        //         mMap.setOnMapClickListener(new GoogleMap.OnMapClickListener() {
        //            
        //            @Override
        //            public void onMapClick(LatLng arg0) {
        //               // TODO Auto-generated method stub
        //               Log.d(TAG, "Simple Click");
        //               
        //            }
        //         });

        mMap.setOnMapLongClickListener(new GoogleMap.OnMapLongClickListener() {
            @Override
            public void onMapLongClick(LatLng arg0) {
                Log.d(TAG, "Long Click");
                //getView().showContextMenu();
                mapView.showContextMenu();
                touchLocation = arg0;
            }
        });

        LocationManager locationManager = (LocationManager) getActivity()
                .getSystemService(Context.LOCATION_SERVICE);
        Location currentLocation = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
        if (currentLocation == null) {
            currentLocation = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
        }
        LatLng currentLatLng = new LatLng(0, 0);
        if (currentLocation != null) {
            currentLatLng = new LatLng(currentLocation.getLatitude(), currentLocation.getLongitude());
        }
        // zoom to cuurent location
        mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(currentLatLng, 17));

    } else {
        Toast.makeText(getActivity(), "Google Play Services are not enabled.", Toast.LENGTH_SHORT).show();
    }

    return v;

}