Skip to content

Instantly share code, notes, and snippets.

@derohimat
Created April 9, 2016 06:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save derohimat/b79e3dd6d650481e7a4c11eba5d14278 to your computer and use it in GitHub Desktop.
Save derohimat/b79e3dd6d650481e7a4c11eba5d14278 to your computer and use it in GitHub Desktop.
private void onPreferedLocationInMap() {
SharedPreferences sharedPreferences = PreferenceManager
.getDefaultSharedPreferences(mContext);
String location = sharedPreferences.getString(getString(R.string.pref_location_key),
getString(R.string.pref_location_default));
Uri geoLocation = Uri.parse("geo:0,0?").buildUpon()
.appendQueryParameter("q", location)
.build();
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(geoLocation);
if (intent.resolveActivity(mContext.getPackageManager()) != null) {
startActivity(intent);
} else {
Log.e(MainActivityFragment.class.getSimpleName(), "Couldn't call " + location + ", no result for this");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment