diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashSearchFragment.java b/OsmAnd/src/net/osmand/plus/dashboard/DashSearchFragment.java index 7483a4f688..b9f18c83c3 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashSearchFragment.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashSearchFragment.java @@ -11,9 +11,11 @@ import android.view.ViewGroup; import android.widget.Button; import android.widget.TextView; +import net.osmand.data.LatLon; import net.osmand.plus.IconsCache; import net.osmand.plus.OsmAndAppCustomization; import net.osmand.plus.R; +import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.search.SearchActivity; import net.osmand.plus.dashboard.tools.DashFragmentData; import net.osmand.plus.helpers.FontCache; @@ -45,11 +47,17 @@ public class DashSearchFragment extends DashBaseFragment { protected void searchActivity(final Activity activity, final OsmAndAppCustomization appCustomization, int tab) { - final Intent search = new Intent(activity, appCustomization.getSearchActivity()); - //search.putExtra(SearchActivity.SHOW_ONLY_ONE_TAB, true); - search.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); + Intent newIntent = new Intent(activity, appCustomization.getSearchActivity()); + // causes wrong position caching: newIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); + LatLon loc = ((MapActivity)activity).getMapLocation(); + newIntent.putExtra(SearchActivity.SEARCH_LAT, loc.getLatitude()); + newIntent.putExtra(SearchActivity.SEARCH_LON, loc.getLongitude()); + if(((MapActivity)activity).getMapViewTrackingUtilities().isMapLinkedToLocation()) { + newIntent.putExtra(SearchActivity.SEARCH_NEARBY, true); + } + newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); getMyApplication().getSettings().SEARCH_TAB.set(tab); - activity.startActivity(search); + activity.startActivity(newIntent); } private void setupButtons(View view) {