I searched other post like this, but I didn't find a solution. Anyone know why I'm getting this message when I select the Preferences form the menu:
Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@44eb7370
The activity is declared in the manifest file.
import com.cartrafficlive.R;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.Menu;
import android.view.MenuItem;
public class ShowMap extends MapActivity{
static final private int MENU_PREFERENCES = Menu.FIRST;
private static final int SHOW_PREFERENCES = 1;
MapController mapController;
String depAdd;
String arrAdd;
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.show_map);
MapView myMapView = (MapView)findViewById(R.id.myMapView);
mapController = myMapView.getController();
myMapView.setSatellite(true);
myMapView.setStreetView(true);
myMapView.displayZoomControls(true);
mapController.setZoom(17);
}
@Override
public boolean onCreateOptionsMenu(Menu menu){
super.onCreateOptionsMenu(menu);
menu.add(0, MENU_PREFERENCES, Menu.NONE, R.string.menu_preferences);
return true;
}
public boolean onOptionItemSelected(MenuItem item){
super.onOptionsItemSelected(item);
switch(item.getItemId()){
case(MENU_PREFERENCES): {
Intent i = new Intent(this, Preferences.class);
startActivityForResult(i, SHOW_PREFERENCES);
return true;
}
}
return false;
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == SHOW_PREFERENCES)
if (resultCode == Activity.RESULT_OK) {
updateFromPreferences();
}
}
private void updateFromPreferences() {
Context context = getApplicationContext();
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
depAdd = prefs.getString(Preferences.PREF_DEP_ADD, "null");
arrAdd = prefs.getString(Preferences.PREF_ARR_ADD, "null");
开发者_StackOverflow社区 }
@Override
protected boolean isRouteDisplayed() {
return false;
}
}
I solve with this line of code:
menu.addIntentOptions(Menu.NONE, Menu.NONE, Menu.NONE, this.getComponentName(), null, i, Menu.NONE, null);
精彩评论