Reputation: 2515
Does anyone know how to activate a map from a quick search box?
My app displays the users location and some places pulled from my website. I have added a quick search box, following instruction from Google Android docs but I can't get it to initiate the map. I can get it to print the query, so I know its getting the data, but when I try to sumbit the query to a class, or set the content view it crashes! (I have commented out the lines that cause a crash).
public class SearchActivity extends MapActivity {
public boolean touched = false;
private MapView mapView;
Main mc = new Main();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.main);
//mapView = (MapView) findViewById(R.id.mapView);
//mapView.getController();
handleIntent(getIntent());
}
private void handleIntent(Intent intent) {
if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
// handles a search query
String query = intent.getStringExtra(SearchManager.QUERY);
//mc.activateMapFromQuery(query);
}
}
@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}
here is what I can read in the LogCat which I believe may be relevant:
Starting Activity: Intent { act=android.intent.action.SEARCH flg=0x10000000 cmp=com.maps.android.example/com.maps.android.example.Main paused=false}
onSignalStrengthChanged
onSignalStrengthChanged
grantUriPermission URI=file:///data/local/tmp/Example.apk
No content provider found for:
Force stopping package com.maps.android.example uid=10115
WIN DEATH: Window{40834690 com.maps.android.example/com.maps.android.example.Main paused=false}
Upvotes: 1
Views: 581
Reputation: 2515
I found the solution!
In the CatLog above it says onSignalStrengthChanged after the Starting Activity. This made me realise that GPS was still updating the user location when it was trying to perform the search and display the new map. So I simply turned off the GPS activity on the initiation of the intent.
This actually sped up the app, and now the search works!
Thanks to everyone who looked at this and tried to help. Hope this is of some assistance to others :)
Upvotes: 1