I get this error when i am selecting a ContextMenu Item to pop up a custom Dialog.
W/InputManagerService(59): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@44f518c0
Code below
public boolean onContextItemSelected(MenuItem item) {
AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
Map<String, String> data = (Map<String, String>) getListView().getItemAtPosition(info.position);
preferences = PreferenceManager.getDefaultSharedPreferences(this);
String user_ids = preferences.getString("userID", null);
switch (item.getItemId()) {
case R.id.pm:
pms(data.get("pid"),user_ids,data.get("Name"));
return true;
}
return super.onContextItemSelected(item);
}
private void pms(final String fu2, final String to,final String to2) {
dialog = new Dialog(this.getParent());
dialog.setContentView(R.layout.popup_reply);
dialog.setTitle("To: "+to2);
dialog.setCancelable(true);
preferences = PreferenceManager.getDefaultSharedPreferences(this);
body = (EditText) dialog.findViewById(R.id.editText2);
sub = (EditText) dialog.findViewById(R.id.editText1);
Button button = (Button) dialog.findViewById(R.id.Button01);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
Button button2 = (Button) dialog.findViewById(R.id.Button02);
button2.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
new ADownloadFileAsync().execute(fu2);
}
});
dialog.show();
}
I am only assuming that the Contextmenu is not out of focus before it calls the dialg. Because I can call the dialog from a button just fine.
The only thing that jumps out at me is the use of the parent context as opposed to the calling activity context when you create the dialog.
Are you sure it doesn’t need to just be
None of the examples I’ve seen so far involve the use of calling the current parent in the constructor.
Also check out the Creating a Custom Dialog section here http://developer.android.com/guide/topics/ui/dialogs.html
and the related bit on Showing a Dialog http://developer.android.com/guide/topics/ui/dialogs.html#ShowingADialog