List of usage examples for android.content Context LOCATION_SERVICE
String LOCATION_SERVICE
To view the source code for android.content Context LOCATION_SERVICE.
Click Source Link
From source file:net.e_fas.oss.tabijiman.MapsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { e_print("onCreate"); // ActionBar? if (savedInstanceState == null) { // customActionBar?? View customActionBarView = this.getActionBarView(); // ActionBar?? ActionBar actionBar = this.getSupportActionBar(); // ?????('<' <- ???) if (actionBar != null) { // ??????? actionBar.setDisplayShowTitleEnabled(false); // icon??????? actionBar.setDisplayShowHomeEnabled(false); // ActionBar?customView? actionBar.setCustomView(customActionBarView); // CutomView?? actionBar.setDisplayShowCustomEnabled(true); }/*ww w . ja v a 2s.co m*/ } // ????? Locale locale = Locale.getDefault(); if (locale.equals(Locale.JAPAN) || locale.equals(Locale.JAPANESE)) { locale = Locale.JAPAN; } else { locale = Locale.ENGLISH; } // ?? Locale.setDefault(locale); Configuration config = new Configuration(); // Resources?? config.locale = locale; Resources resources = getBaseContext().getResources(); // Resources?????? resources.updateConfiguration(config, null); super.onCreate(savedInstanceState); setContentView(R.layout.activity_maps); try { new CreateInitData(this).exec(locale); new SPARQL().query(AppSetting.query_place, "place"); new SPARQL().query(AppSetting.query_frame, "frame"); } catch (IOException | JSONException e) { e.printStackTrace(); } makeTempDir(); // ??? ConnectivityManager connMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connMgr.getActiveNetworkInfo(); if (networkInfo == null) { Toast.makeText(getApplicationContext(), "???????????", Toast.LENGTH_LONG).show(); } buttons = new ArrayList<>(); View.OnClickListener change_button = new View.OnClickListener() { @Override public void onClick(View v) { CameraPosition cameraPos; if (v == TrainButton) { zoomLevel = 9.0f; cameraPos = new CameraPosition.Builder() .target(new LatLng(nowLocation.latitude, nowLocation.longitude)).zoom(zoomLevel) .bearing(0).build(); } else if (v == CarButton) { zoomLevel = 11.0f; cameraPos = new CameraPosition.Builder() .target(new LatLng(nowLocation.latitude, nowLocation.longitude)).zoom(zoomLevel) .bearing(0).build(); } else { zoomLevel = 14.0f; cameraPos = new CameraPosition.Builder() .target(new LatLng(nowLocation.latitude, nowLocation.longitude)).zoom(zoomLevel) .bearing(0).build(); } if (!v.isActivated()) { v.setActivated(true); for (int i = 0; i < buttons.size(); i++) { if (buttons.get(i) != v) { buttons.get(i).setActivated(false); } } } mMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPos)); } }; View.OnClickListener marker_change_button = new View.OnClickListener() { @Override public void onClick(View v) { if (!v.isActivated()) { v.setActivated(true); if (v == FrameSwitch) { setMarker("frame"); FrameMarkerOptions.clear(); } else { setMarker("place"); PlaceMarkerOptions.clear(); } } else { v.setActivated(false); if (v == FrameSwitch) { for (Marker m : FrameMarker) { m.remove(); } FrameMarker.clear(); } else { for (Marker m : PlaceMarker) { m.remove(); } PlaceMarker.clear(); } } } }; // LocationManager? mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); TakePicture = (ImageButton) findViewById(R.id.takePicture); TakePicture.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent TakePictureView = new Intent(getApplicationContext(), TakePicture.class); startActivity(TakePictureView); } }); TrainButton = (ImageButton) findViewById(R.id.Train); TrainButton.setActivated(false); TrainButton.setOnClickListener(change_button); CarButton = (ImageButton) findViewById(R.id.Car); CarButton.setActivated(true); CarButton.setOnClickListener(change_button); WalkButton = (ImageButton) findViewById(R.id.Walk); WalkButton.setActivated(false); WalkButton.setOnClickListener(change_button); buttons = Arrays.asList(TrainButton, CarButton, WalkButton); FrameSwitch = (ImageButton) findViewById(R.id.showFrame); FrameSwitch.setActivated(true); FrameSwitch.setOnClickListener(marker_change_button); PlaceSwitch = (ImageButton) findViewById(R.id.showPlace); PlaceSwitch.setActivated(true); PlaceSwitch.setOnClickListener(marker_change_button); GoFukuiButton = (ImageButton) findViewById(R.id.GoFukuiButton); // new AppSetting(this); // AppSetting.context = getApplicationContext(); AppSetting.Inc_CountRun(); e_print("Run_Count >> " + AppSetting.CountRun()); if (AppSetting.CountRun() % 20 == 0) { GoFukuiButton.setVisibility(View.VISIBLE); } FrameCollectionButton = (ImageButton) findViewById(R.id.frameCollection); FrameCollectionButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent collection = new Intent(getApplicationContext(), FrameCollection.class); startActivity(collection); } }); mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map); mapFragment.getMapAsync(this); // mapFragment.getMap(); helper = new SQLiteHelper(this); db = helper.getWritableDatabase(); }
From source file:com.hufeiya.SignIn.activity.QuizActivity.java
private void getLocation() { locationManager = (LocationManager) MyApplication.getContext().getSystemService(Context.LOCATION_SERVICE); if (ActivityCompat.checkSelfPermission(MyApplication.getContext(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(MyApplication.getContext(), Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { Toast.makeText(QuizActivity.this, "??? ( > c < ) ", Toast.LENGTH_SHORT).show(); String locationPermissions[] = { Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION }; int currentapiVersion = android.os.Build.VERSION.SDK_INT; if (currentapiVersion >= 23) { requestPermissions(locationPermissions, REQUEST_CODE_FOR_POSITON); }/*w w w . j a va2s. co m*/ return; } locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 0, this); locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 1000, 0, this); }
From source file:edu.princeton.jrpalmer.asmlibrary.Settings.java
@Override protected void onResume() { if (Util.trafficCop(this)) finish();//from w w w . j a v a2 s . c o m IntentFilter uploadFilter; uploadFilter = new IntentFilter( getResources().getString(R.string.internal_message_id) + Util.MESSAGE_FIX_UPLOADED); uploadReceiver = new UploadReceiver(); registerReceiver(uploadReceiver, uploadFilter); IntentFilter fixFilter; fixFilter = new IntentFilter( getResources().getString(R.string.internal_message_id) + Util.MESSAGE_FIX_RECORDED); fixReceiver = new FixReceiver(); registerReceiver(fixReceiver, fixFilter); shareMyData = PropertyHolder.getShareData(); toggleParticipationViews(shareMyData); int nUploads = PropertyHolder.getNUploads(); final long participationTime = PropertyHolder.ptCheck(); participationTimeText.setBase(SystemClock.elapsedRealtime() - participationTime); // service button boolean isServiceOn = PropertyHolder.isServiceOn(); mServiceButton.setChecked(isServiceOn); mServiceButton.setOnClickListener(new ToggleButton.OnClickListener() { public void onClick(View view) { if (view.getId() != R.id.service_button) return; Context context = view.getContext(); boolean on = ((ToggleButton) view).isChecked(); String schedule = on ? Util.MESSAGE_SCHEDULE : Util.MESSAGE_UNSCHEDULE; // Log.e(TAG, schedule + on); // now schedule or unschedule Intent intent = new Intent(getString(R.string.internal_message_id) + schedule); context.sendBroadcast(intent); showSpinner(on, storeMyData); if (on && shareMyData) { final long ptNow = PropertyHolder.ptStart(); participationTimeText.setBase(SystemClock.elapsedRealtime() - ptNow); participationTimeText.start(); ContentResolver ucr = getContentResolver(); ucr.insert(Util.getUploadQueueUri(context), UploadContentValues.createUpload("ONF", "on," + Util.iso8601(System.currentTimeMillis()) + "," + ptNow)); } else { final long ptNow = PropertyHolder.ptStop(); participationTimeText.setBase(SystemClock.elapsedRealtime() - ptNow); participationTimeText.stop(); // stop uploader Intent stopUploaderIntent = new Intent(Settings.this, FileUploader.class); // Stop service if it is currently running stopService(stopUploaderIntent); if (shareMyData) { ContentResolver ucr = getContentResolver(); ucr.insert(Util.getUploadQueueUri(context), UploadContentValues.createUpload("ONF", "off," + Util.iso8601(System.currentTimeMillis()) + "," + ptNow)); } } // If user turns CountdownDisplay on but GPS is not on, remind // user to turn // GPS on if (on) { final LocationManager manager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); if (!manager.isProviderEnabled(LocationManager.GPS_PROVIDER)) { if (!manager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) { buildAlertMessageNoGpsNoNet(); } else buildAlertMessageNoGps(); } } return; } }); // interval spinner int intspinner_item = android.R.layout.simple_spinner_item; int dropdown_item = android.R.layout.simple_spinner_dropdown_item; ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.interval_array, intspinner_item); adapter.setDropDownViewResource(dropdown_item); mIntervalSpinner.setAdapter(adapter); mIntervalSpinner.setOnItemSelectedListener(new Spinner.OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parent, View v, int pos, long id) { int parentId = parent.getId(); if (parentId != R.id.spinner_interval) return; if (pos > mInterval.length) return; if (!PropertyHolder.isServiceOn()) { PropertyHolder.setAlarmInterval(mInterval[pos]); return; } PropertyHolder.setAlarmInterval(mInterval[pos]); mServiceButton.setChecked(true); Intent intent = new Intent(getString(R.string.internal_message_id) + Util.MESSAGE_SCHEDULE); Context context = getApplicationContext(); context.sendBroadcast(intent); showSpinner(true, storeMyData); if (shareMyData) { ContentResolver ucr = getContentResolver(); ucr.insert(Util.getUploadQueueUri(context), UploadContentValues.createUpload("INT", Util.iso8601(System.currentTimeMillis()) + "," + mInterval[pos])); } } public void onNothingSelected(AdapterView<?> parent) { // do nothing } }); int pos = ai2pos(PropertyHolder.getAlarmInterval()); mIntervalSpinner.setSelection(pos); showSpinner(isServiceOn, storeMyData); // mydata buttons // storage spinner storageDays = PropertyHolder.getStorageDays(); mStorageSpinner.setOnItemSelectedListener(new Spinner.OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parent, View v, int pos, long id) { int parentId = parent.getId(); if (parentId != R.id.spinner_mydata) return; if (pos > MAX_STORAGE - MIN_STORAGE) return; PropertyHolder.setStorageDays(pos + MIN_STORAGE); PropertyHolder.setStoreMyData((pos + MIN_STORAGE) > 0); } public void onNothingSelected(AdapterView<?> parent) { // do nothing } }); int storagepos = storageDays - MIN_STORAGE; mStorageSpinner.setSelection(storagepos); // NEW STUFF mToggleSatRadioGroup = (RadioGroup) findViewById(R.id.toggleSatRadioGroup); mToggleIconsRadioGroup = (RadioGroup) findViewById(R.id.toggleIconsRadioGroup); mToggleAccRadioGroup = (RadioGroup) findViewById(R.id.toggleAccRadioGroup); mLimitStartDateRadioGroup = (RadioGroup) findViewById(R.id.limitStartDateRadioGroup); mLimitEndDateRadioGroup = (RadioGroup) findViewById(R.id.limitEndDateRadioGroup); Intent i = getIntent(); if (i.getBooleanExtra(MapMyData.DATES_BUTTON_MESSAGE, false)) { RelativeLayout dateSettingsArea = (RelativeLayout) findViewById(R.id.dateSettingsArea); dateSettingsArea.setFocusable(true); dateSettingsArea.setFocusableInTouchMode(true); dateSettingsArea.requestFocus(); } if (shareMyData && isServiceOn) { participationTimeText.setBase(SystemClock.elapsedRealtime() - PropertyHolder.ptStart()); participationTimeText.start(); } nUploadsText.setText(String.valueOf(nUploads)); if (nUploads >= Util.UPLOADS_TO_PRO && !PropertyHolder.getProVersion() && participationTime >= Util.TIME_TO_PRO) { Util.createProNotification(context); PropertyHolder.setProVersion(true); PropertyHolder.setNeedsDebriefingSurvey(true); } boolean proV = PropertyHolder.getProVersion(); // 19 December 2013: end of research changes mShareDataRadioGroup.check(R.id.sharedataNo); mShareDataRadioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { if (checkedId == R.id.sharedataYes) { buildSharingOverAnnouncement(); } mShareDataRadioGroup.check(R.id.sharedataNo); } }); /* * if (proV) { * * if (shareMyData) { mShareDataRadioGroup.check(R.id.sharedataYes); if * (PropertyHolder.isRegistered() == false || * PropertyHolder.hasConsented() == false) { send2Intro(context); } } * else { mShareDataRadioGroup.check(R.id.sharedataNo); } * * mShareDataRadioGroup .setOnCheckedChangeListener(new * OnCheckedChangeListener() { * * @Override public void onCheckedChanged(RadioGroup group, int * checkedId) { shareMyData = (checkedId == R.id.sharedataYes); * PropertyHolder.setShareData(shareMyData); * toggleParticipationViews(shareMyData); final boolean on = * PropertyHolder.isServiceOn(); if (shareMyData) { if * (PropertyHolder.isRegistered() == false || * PropertyHolder.hasConsented() == false) { send2Intro(context); * * } if (on) { * * final long ptNow = PropertyHolder.ptStart(); * participationTimeText.setBase(SystemClock .elapsedRealtime() - * ptNow); * * participationTimeText.start(); * * ContentResolver ucr = getContentResolver(); * * ucr.insert( Util.getUploadQueueUri(context), * UploadContentValues.createUpload( "ONF", "on," + Util.iso8601(System * .currentTimeMillis()) + "," + ptNow)); * * } } else { * * final long ptNow = PropertyHolder.ptStop(); * participationTimeText.setBase(SystemClock .elapsedRealtime() - * ptNow); participationTimeText.stop(); // stop uploader Intent i = new * Intent(Settings.this, FileUploader.class); // Stop service if it is * currently running stopService(i); * * if (on) { ContentResolver ucr = getContentResolver(); * * ucr.insert( Util.getUploadQueueUri(context), * UploadContentValues.createUpload( "ONF", "off," + Util.iso8601(System * .currentTimeMillis()) + "," + ptNow)); * * } * * } * * } }); } else { mShareDataRadioGroup.check(R.id.sharedataYes); * mShareDataRadioGroup .setOnCheckedChangeListener(new * OnCheckedChangeListener() { * * @Override public void onCheckedChanged(RadioGroup group, int * checkedId) { if (checkedId == R.id.sharedataNo) { * mShareDataRadioGroup.check(R.id.sharedataYes); * showCurrentlySharingDialog(); } } }); * * } */ new CheckPendingUploadsSizeTask().execute(context); new CheckUserDbSizeTask().execute(context); deletePendingUploadsButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { ContentResolver cr = getContentResolver(); final int nDeleted = cr.delete(Util.getUploadQueueUri(context), "1", null); // Log.i("Settings", "number of rows deleted=" + nDeleted); Util.toast(context, String.valueOf(nDeleted) + " " + getResources().getString(R.string.locations_deleted) + "."); updateStorageSizes(); } }); deleteUserDbButton = (ImageButton) findViewById(R.id.deleteMyDbButton); deleteUserDbButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { ContentResolver cr = getContentResolver(); final int nDeleted = cr.delete(Util.getFixesUri(context), "1", null); Util.toast(context, String.valueOf(nDeleted) + " " + getResources().getString(R.string.locations_deleted) + "."); updateStorageSizes(); } }); uploadButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (Util.isOnline(context)) { Intent i = new Intent(Settings.this, FileUploader.class); startService(i); new UploadMessageTask().execute(context); } else { Util.toast(context, getResources().getString(R.string.offline_warning)); } } }); mToggleSatRadioGroup.check(PropertyHolder.getMapSat() ? R.id.toggleSatYes : R.id.toggleSatNo); mToggleSatRadioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { PropertyHolder.setMapSat(checkedId == R.id.toggleSatYes); } }); mToggleIconsRadioGroup.check(PropertyHolder.getMapIcons() ? R.id.toggleIconsYes : R.id.toggleIconsNo); mToggleIconsRadioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { PropertyHolder.setMapIcons(checkedId == R.id.toggleIconsYes); } }); mToggleAccRadioGroup.check(PropertyHolder.getMapAcc() ? R.id.toggleAccYes : R.id.toggleAccNo); mToggleAccRadioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { PropertyHolder.setMapAcc(checkedId == R.id.toggleAccYes); } }); mStartDateButton = (Button) findViewById(R.id.startDateButton); mEndDateButton = (Button) findViewById(R.id.endDateButton); boolean limitStartDate = PropertyHolder.getLimitStartDate(); boolean limitEndDate = PropertyHolder.getLimitEndDate(); if (!limitStartDate) mStartDateButton.setVisibility(View.GONE); else { mStartDateButton.setVisibility(View.VISIBLE); } if (!limitEndDate) mEndDateButton.setVisibility(View.GONE); else { mEndDateButton.setVisibility(View.VISIBLE); } mLimitStartDateRadioGroup.check(limitStartDate ? R.id.limitStartDateYes : R.id.limitStartDateNo); mLimitStartDateRadioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { PropertyHolder.setLimitStartDate(checkedId == R.id.limitStartDateYes); if (checkedId != R.id.limitStartDateYes) mStartDateButton.setVisibility(View.GONE); else { mStartDateButton.setVisibility(View.VISIBLE); } } }); mLimitEndDateRadioGroup.check(limitEndDate ? R.id.limitEndDateYes : R.id.limitEndDateNo); mLimitEndDateRadioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { PropertyHolder.setLimitEndDate(checkedId == R.id.limitEndDateYes); if (checkedId != R.id.limitEndDateYes) mEndDateButton.setVisibility(View.GONE); else { mEndDateButton.setVisibility(View.VISIBLE); } } }); mStartDateButton.setText(Util.userDateNoTime(PropertyHolder.getMapStartDate())); mStartDateButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { DialogFragment newFragment = new StartDatePickerFragment(); newFragment.show(getSupportFragmentManager(), "datePicker"); } }); mEndDateButton.setText(Util.userDateNoTime(PropertyHolder.getMapEndDate())); mEndDateButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { DialogFragment newFragment = new EndDatePickerFragment(); newFragment.show(getSupportFragmentManager(), "datePicker"); } }); if (PropertyHolder.getNeedsDebriefingSurvey()) { buildProAnnouncement(); PropertyHolder.setNeedsDebriefingSurvey(false); } super.onResume(); }
From source file:org.csp.everyaware.offline.Map.java
@Override protected void onStart() { super.onStart(); // This verification should be done during onStart() because the system calls // this method when the user returns to the activity, which ensures the desired // location provider is enabled each time the activity resumes from the stopped state. LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); final boolean gpsEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER); if (!gpsEnabled) { // Build an alert dialog here that requests that the user enable // the location services, then when the user clicks the "OK" button, // call enableLocationSettings() }/*from w ww . ja v a 2s . co m*/ }
From source file:com.ternup.caddisfly.fragment.LocationFragment.java
/** * Invoked by the "Start Updates" button * Sends a request to start location updates * * @param v The view object associated with this method, in this case a Button. *///from www .jav a2 s . c o m public void startUpdates(View v) { // Get Location Manager and check for GPS & Network location services LocationManager lm = (LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE); if (!lm.isProviderEnabled(LocationManager.GPS_PROVIDER) || !lm.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) { // Build the alert dialog AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle("Location Services Not Active"); builder.setMessage("Please enable Location Services and GPS"); builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialogInterface, int i) { // Show location settings when the user acknowledges the alert dialog Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); startActivity(intent); } }); Dialog alertDialog = builder.create(); alertDialog.setCanceledOnTouchOutside(false); alertDialog.show(); } else { mUpdatesRequested = true; if (servicesConnected()) { // Turn the indefinite activity indicator on mActivityIndicator.setVisibility(View.VISIBLE); mLocationButton.setVisibility(View.GONE); startPeriodicUpdates(); } } }
From source file:com.metinkale.prayerapp.compass.Main.java
@Override public void onLocationChanged(Location location) { if ((System.currentTimeMillis() - location.getTime()) < (mOnlyNew ? (1000 * 60) : (1000 * 60 * 60 * 24))) { LocationManager locMan = (LocationManager) getSystemService(Context.LOCATION_SERVICE); locMan.removeUpdates(this); }// w ww . j ava 2 s. c o m }
From source file:com.example.b1013029.myapplication.MapsActivity.java
private void setMyLocation() { LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); Location lastLocate = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); if (lastLocate != null) { LatLng position = new LatLng(lastLocate.getLatitude(), lastLocate.getLongitude()); this.gMap.animateCamera(CameraUpdateFactory.newLatLngZoom(position, gMap.getCameraPosition().zoom)); } else {/*from www. j a v a 2 s. c o m*/ Toast.makeText(this, "????????", Toast.LENGTH_SHORT).show(); } }
From source file:com.tingbacke.wearmaps.MobileActivity.java
/** * This is where we can add markers or lines, add listeners or move the camera. In this case, we * just add a marker near Africa.//w ww . j a v a 2 s . com * <p/> * This should only be called once and when we are sure that {@link #mMap} is not null. */ private void setUpMap() { mMap.setMapType(GoogleMap.MAP_TYPE_HYBRID); mMap.setMyLocationEnabled(true); /** * https://geolocation.ws/map/55.588227,13.002735/13/en?types=&limit=300&licenses= * Dammfrivgen 61 = 55.587116, 12.979788 */ /* mMap.addMarker(new MarkerOptions().position(new LatLng(55.61015, 12.9786)).title("Cykelpump Kockums Torg")); mMap.addMarker(new MarkerOptions().position(new LatLng(55.5877, 12.9887)).title("Cykelpump Malm gamla stadion")); mMap.addMarker(new MarkerOptions().position(new LatLng(55.6093, 12.9967)).title("Cykelpump, Anna Linds plats")); mMap.addMarker(new MarkerOptions().position(new LatLng(55.6025, 12.9679)).title("Cykelpump, Ribersborgsstigen")); mMap.addMarker(new MarkerOptions().position(new LatLng(55.6131, 12.9767)).title("Turning Torso")); mMap.addMarker(new MarkerOptions().position(new LatLng(55.6140, 12.9839)).title("Stapelbddsparken, skatepark")); mMap.addMarker(new MarkerOptions().position(new LatLng(55.6125, 12.9914)).title("Media Evolution City")); mMap.addMarker(new MarkerOptions().position(new LatLng(55.6144, 12.9895)).title("Doc Piazza Trattoria")); mMap.addMarker(new MarkerOptions().position(new LatLng(55.6156, 12.9857)).title("Kranen K3, Malm Hgskola")); mMap.addMarker(new MarkerOptions().position(new LatLng(55.6150, 12.9858)).title("Ubtshallen")); mMap.addMarker(new MarkerOptions().position(new LatLng(55.6108, 12.9949)).title("Orkanen, Malm Hgskola")); mMap.addMarker(new MarkerOptions().position(new LatLng(55.5850, 12.9873)).title("Swedbank Stadion")); mMap.addMarker(new MarkerOptions().position(new LatLng(55.5922, 12.9975)).title("Pildammsparken Entr")); mMap.addMarker(new MarkerOptions().position(new LatLng(55.5901, 12.9887)).title("Pildammsparken Tallriken")); mMap.addMarker(new MarkerOptions().position(new LatLng(55.5890, 12.9825)).title("Jet bensinmack, Lorensborg")); mMap.addMarker(new MarkerOptions().position(new LatLng(55.6048, 12.9658)).title("Ribersborgs Kallbadhus")); mMap.addMarker(new MarkerOptions().position(new LatLng(55.6041, 12.9735)).title("Toalett, Ribersborgsstigen")); mMap.addMarker(new MarkerOptions().position(new LatLng(55.6086, 12.9774)).title("Kockum fritid")); mMap.addMarker(new MarkerOptions().position(new LatLng(55.6138, 12.9812)).title("Varvsparken")); mMap.addMarker(new MarkerOptions().position(new LatLng(55.6137, 12.9725)).title("Daniabadet, Vstra Hamnen")); mMap.addMarker(new MarkerOptions().position(new LatLng(55.6171, 12.9744)).title("Scaniabadet, Vstra Hamnen")); mMap.addMarker(new MarkerOptions().position(new LatLng(55.5967, 13.0053)).title("MALM")); mMap.addMarker(new MarkerOptions().position(new LatLng(55.5986, 12.9836)).title("Kronprinsen")); //mMap.addMarker(new MarkerOptions().position(new LatLng()).title("")); */ // Get LocationManager object from System Service LOCATION_SERVICE LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); // Create a criteria object to retrieve provider Criteria criteria = new Criteria(); // Get the name of the best provider String provider = locationManager.getBestProvider(criteria, true); // Get Current Location Location myLocation = locationManager.getLastKnownLocation(provider); // Get latitude of the current location double latitude = myLocation.getLatitude(); // Get longitude of the current location double longitude = myLocation.getLongitude(); // Create a LatLng object for the current location LatLng latLng = new LatLng(latitude, longitude); // Show the current location in Google Map mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng)); CameraPosition cameraPosition = new CameraPosition.Builder().target(latLng).zoom(18).bearing(0).tilt(25) .build(); mMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition)); LatLng myCoordinates = new LatLng(latitude, longitude); CameraUpdate yourLocation = CameraUpdateFactory.newLatLngZoom(myCoordinates, 18); mMap.animateCamera(yourLocation); }
From source file:com.piusvelte.sonet.core.SonetCreatePost.java
@Override public boolean onOptionsItemSelected(MenuItem item) { int itemId = item.getItemId(); if (itemId == R.id.menu_post_accounts) chooseAccounts();/*from ww w. j a va 2 s . c o m*/ else if (itemId == R.id.menu_post_photo) { boolean supported = false; Iterator<Integer> services = mAccountsService.values().iterator(); while (services.hasNext() && ((supported = sPhotoSupported.contains(services.next())) == false)) ; if (supported) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(Intent.createChooser(intent, "Select Picture"), PHOTO); } else unsupportedToast(sPhotoSupported); // } else if (itemId == R.id.menu_post_tags) { // if (mAccountsService.size() == 1) { // if (sTaggingSupported.contains(mAccountsService.values().iterator().next())) // selectFriends(mAccountsService.keySet().iterator().next()); // else // unsupportedToast(sTaggingSupported); // } else { // // dialog to select an account // Iterator<Long> accountIds = mAccountsService.keySet().iterator(); // HashMap<Long, String> accountEntries = new HashMap<Long, String>(); // while (accountIds.hasNext()) { // Long accountId = accountIds.next(); // Cursor account = this.getContentResolver().query(Accounts.getContentUri(this), new String[]{Accounts._ID, ACCOUNTS_QUERY}, Accounts._ID + "=?", new String[]{Long.toString(accountId)}, null); // if (account.moveToFirst() && sTaggingSupported.contains(mAccountsService.get(accountId))) // accountEntries.put(account.getLong(0), account.getString(1)); // } // int size = accountEntries.size(); // if (size != 0) { // final long[] accountIndexes = new long[size]; // final String[] accounts = new String[size]; // int i = 0; // Iterator<Map.Entry<Long, String>> entries = accountEntries.entrySet().iterator(); // while (entries.hasNext()) { // Map.Entry<Long, String> entry = entries.next(); // accountIndexes[i] = entry.getKey(); // accounts[i++] = entry.getValue(); // } // mDialog = (new AlertDialog.Builder(this)) // .setTitle(R.string.accounts) // .setSingleChoiceItems(accounts, -1, new DialogInterface.OnClickListener() { // @Override // public void onClick(DialogInterface dialog, int which) { // selectFriends(accountIndexes[which]); // dialog.dismiss(); // } // }) // .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { // @Override // public void onClick(DialogInterface dialog, int which) { // dialog.dismiss(); // } // }) // .create(); // mDialog.show(); // } else // unsupportedToast(sTaggingSupported); // } } else if (itemId == R.id.menu_post_location) { LocationManager locationManager = (LocationManager) SonetCreatePost.this .getSystemService(Context.LOCATION_SERVICE); Location location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); if (location != null) { mLat = Double.toString(location.getLatitude()); mLong = Double.toString(location.getLongitude()); if (mAccountsService.size() == 1) { if (sLocationSupported.contains(mAccountsService.values().iterator().next())) setLocation(mAccountsService.keySet().iterator().next()); else unsupportedToast(sLocationSupported); } else { // dialog to select an account Iterator<Long> accountIds = mAccountsService.keySet().iterator(); HashMap<Long, String> accountEntries = new HashMap<Long, String>(); while (accountIds.hasNext()) { Long accountId = accountIds.next(); Cursor account = this.getContentResolver().query(Accounts.getContentUri(this), new String[] { Accounts._ID, ACCOUNTS_QUERY }, Accounts._ID + "=?", new String[] { Long.toString(accountId) }, null); if (account.moveToFirst() && sLocationSupported.contains(mAccountsService.get(accountId))) accountEntries.put(account.getLong(account.getColumnIndex(Accounts._ID)), account.getString(account.getColumnIndex(Accounts.USERNAME))); } int size = accountEntries.size(); if (size != 0) { final long[] accountIndexes = new long[size]; final String[] accounts = new String[size]; int i = 0; Iterator<Map.Entry<Long, String>> entries = accountEntries.entrySet().iterator(); while (entries.hasNext()) { Map.Entry<Long, String> entry = entries.next(); accountIndexes[i] = entry.getKey(); accounts[i++] = entry.getValue(); } mDialog = (new AlertDialog.Builder(this)).setTitle(R.string.accounts) .setSingleChoiceItems(accounts, -1, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { setLocation(accountIndexes[which]); dialog.dismiss(); } }) .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }).create(); mDialog.show(); } else unsupportedToast(sLocationSupported); } } else (Toast.makeText(this, getString(R.string.location_unavailable), Toast.LENGTH_LONG)).show(); } return super.onOptionsItemSelected(item); }