Can popupWindow in android be shown again after one dismiss? I can't do it












0














I have an Activity in my android project.
With a click on a Button, a popupWindow appears.
Everything goes fine until I press back in popupWindow and get back to activity and click on the Button again. Everything freezes and the application stops.



My popupWindow has customized view. Its view consists of a SearchView, ExpandableListView, and a Button to submit. The expandableListView retrieves Phone contacts.
I searched for the problem, but they had problems with dismissing on back pressed, which is not what I'm dealing with.



Button import_contact = findViewById(R.id.import_contact);
import_contact.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
LayoutInflater inflater = (LayoutInflater)
getSystemService(LAYOUT_INFLATER_SERVICE);
View popupView = inflater.inflate(R.layout.import_contacts_window, null);
int width = LinearLayout.LayoutParams.MATCH_PARENT;
int height = LinearLayout.LayoutParams.MATCH_PARENT;
PopupWindow popupWindow = new PopupWindow(popupView, width, height, true);
popupWindow.setOutsideTouchable(true);
popupWindow.setBackgroundDrawable(new ColorDrawable(Color.GRAY));
popupWindow.setContentView(popupView);
popupWindow.showAtLocation(findViewById(R.id.contacts_container), Gravity.CENTER, 0, 0);
popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
@Override
public void onDismiss() {
Log.e("dismiss", "true");
}
});

contactsListView = popupView.findViewById(R.id.phone_contacts_list);
contactsListDataAdapter = new ContactListAdapter(MainActivity.this,
expandableListTitle,
expandableListDetail);
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
int w = metrics.widthPixels;
contactsListView.setIndicatorBounds(w - 30, w - 6);
contactsListView.setAdapter(contactsListDataAdapter);
SearchManager searchManager = (SearchManager)
getSystemService(Context.SEARCH_SERVICE);
search = popupView.findViewById(R.id.searchContacts);
search.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
search.setIconifiedByDefault(false);
search.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
Log.e("onQueryTextSubmit", "1");
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
Log.e("onQueryTextChange", " ");
contactsListDataAdapter.filterData(newText);
expandAll();
return true;
}
});
search.setOnCloseListener(new SearchView.OnCloseListener() {
@Override
public boolean onClose() {
Log.e("onClose", " ");
return false;
}
});
Button OK = popupView.findViewById(R.id.OK);
OK.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO: verify OK from Client with a popup dialog
}
});
if (!hasPhoneContactsPermission(Manifest.permission.READ_CONTACTS)) {
requestPermission(Manifest.permission.READ_CONTACTS, PERMISSION_REQUEST_CODE_READ_CONTACTS);
} else {
readPhoneContacts();
}
}
});


Here is the log after popupwindow dismissed and after I pressed on the button to reopen the popupWindow:



12-27 03:57:31.925 16287-16287/com.ghasedakia E/dismiss: true
12-27 03:57:31.925 16287-16287/com.ghasedakia W/InputEventReceiver:
Attempted to finish an input event but the input event receiver has already
been disposed.
12-27 03:57:50.765 151-179/? W/AudioPolicyManagerBase: getOutput() could not
find output for stream 1, samplingRate 0,format 0, channels 3, flags 0
12-27 03:57:50.765 151-151/? W/AudioPolicyManagerBase: getOutput() could not
find output for stream 1, samplingRate 0,format 0, channels 3, flags 0
12-27 03:57:50.765 151-11050/? W/AudioPolicyManagerBase: getOutput() could
not find output for stream 1, samplingRate 44100,format 1, channels 1, flags
4
12-27 03:57:50.765 313-426/system_process E/AudioTrack: Could not get audio
output for stream type 1
12-27 03:57:50.765 313-426/system_process E/SoundPool: Error creating
AudioTrack
12-27 03:57:50.905 493-496/com.android.phone D/dalvikvm: GC_CONCURRENT freed
384K, 6% free 11238K/11847K, paused 0ms+0ms, total 2ms


After some time passed, the application crashed with the following log:



12-27 04:34:12.977 313-392/system_process I/InputDispatcher: Application is 
not responding: Window{53799ea0 com.ghasedakia/com.ghasedakia.MainActivity
paused=false}. It has been 5003.3ms since event, 5003.3ms since wait started.
Reason: Waiting because the touched window has not finished processing the input
events that were previously delivered to it.
12-27 04:34:12.977 313-392/system_process I/WindowManager: Input event
dispatching timed out sending to com.ghasedakia/com.ghasedakia.MainActivity
12-27 04:34:12.981 313-392/system_process I/Process: Sending signal. PID: 16861
SIG: 3
12-27 04:34:12.989 16861-16866/com.ghasedakia I/dalvikvm: threadid=3: reacting
to signal 3
12-27 04:34:12.989 313-316/system_process D/dalvikvm: GC_CONCURRENT freed 784K,
15% free 13983K/16391K, paused 1ms+1ms, total 10ms
12-27 04:34:13.001 16861-16866/com.ghasedakia I/dalvikvm: Wrote stack traces to
'/data/anr/traces.txt'
12-27 04:34:13.005 313-392/system_process I/Process: Sending signal. PID: 313
SIG: 3
12-27 04:34:13.005 313-318/system_process I/dalvikvm: threadid=3: reacting to
signal 3
12-27 04:34:13.077 313-325/system_process E/Sensors: Select fail, disconnect all
clients (errno=4)
12-27 04:34:13.089 313-318/system_process I/dalvikvm: Wrote stack traces to
'/data/anr/traces.txt'
12-27 04:34:13.113 313-392/system_process I/Process: Sending signal. PID: 493
SIG: 3
12-27 04:34:13.113 493-500/com.android.phone I/dalvikvm: threadid=3: reacting to
signal 3
12-27 04:34:13.113 313-316/system_process D/dalvikvm: GC_CONCURRENT freed 42K,
15% free 13941K/16391K, paused 11ms+11ms, total 26ms
12-27 04:34:13.141 493-500/com.android.phone I/dalvikvm: Wrote stack traces to
'/data/anr/traces.txt'
12-27 04:34:13.141 313-392/system_process I/Process: Sending signal. PID: 432
SIG: 3
12-27 04:34:13.141 432-437/com.android.systemui I/dalvikvm: threadid=3: reacting
to signal 3
12-27 04:34:13.153 432-437/com.android.systemui I/dalvikvm: Wrote stack traces
to '/data/anr/traces.txt'
12-27 04:34:13.201 313-316/system_process D/dalvikvm: GC_CONCURRENT freed 521K,
14% free 14148K/16391K, paused 12ms+1ms, total 24ms
12-27 04:34:13.201 313-392/system_process D/dalvikvm: WAIT_FOR_CONCURRENT_GC
blocked 12ms
12-27 04:34:13.205 313-392/system_process D/dalvikvm: GC_EXPLICIT freed 17K, 14%
free 14131K/16391K, paused 0ms+1ms, total 8ms
12-27 04:34:13.713 313-392/system_process E/ActivityManager: ANR in
com.ghasedakia (com.ghasedakia/.MainActivity)
Reason: keyDispatchingTimedOut
Load: 0.69 / 0.34 / 0.45
CPU usage from 7981ms to 0ms ago:
99% 16861/com.ghasedakia: 99% user + 0% kernel
100% TOTAL: 99% user + 0.2% kernel
CPU usage from 227ms to 731ms later:
94% 16861/com.ghasedakia: 94% user + 0% kernel
94% 16861/com.ghasedakia: 94% user + 0% kernel
100% TOTAL: 100% user + 0% kernel
12-27 04:34:13.749 313-316/system_process D/dalvikvm: GC_CONCURRENT freed 412K,
12% free 14568K/16391K, paused 12ms+1ms, total 27ms
12-27 04:34:13.749 313-16887/system_process D/dalvikvm: WAIT_FOR_CONCURRENT_GC
blocked 16ms
12-27 04:34:13.757 313-16887/system_process D/dalvikvm: GC_FOR_ALLOC freed 459K,
13% free 14275K/16391K, paused 9ms, total 9ms
12-27 04:34:16.081 313-325/system_process D/Sensors: Client connection accepted
(232)


I saw this page,
https://blog.csdn.net/geekqian/article/details/70279076



I think the problem is the same as me. But I cant setFocusable to false because I need to handle clicks on my popupWindow.



I expect that each time a click on the Button occurs, the popupWindow be shown. But the second time I touch the Button, the application freezes. Any ideas where the problem is?










share|improve this question
























  • When you say 'Everything freezes and the application stops', you must get an error in the error log. Can you share that.
    – Nero
    Dec 27 '18 at 21:01










  • override onBackPressed() and call popUpWindow.dismiss() if it work's i will post it as an answer with explanation. :D
    – Anmol
    Dec 28 '18 at 5:31












  • @Anmol I checked. When I press back on popupWindow, it doesn't trigger onBackPressed in my Activity. And popupWindow dismisses. I checked it with a Log.e in the first of onDissmissListener and onBackPressed overridden.
    – Nahid Ataei
    Dec 28 '18 at 5:59












  • @Nero I added the log after I press the Button in my question, but nothing helpful I think.
    – Nahid Ataei
    Dec 28 '18 at 6:03










  • @NahidAtaei Add popUpWindow.dismiss() right before log.e("dismiss","true") as suggested and try again.
    – kowie le roux
    Dec 28 '18 at 6:11
















0














I have an Activity in my android project.
With a click on a Button, a popupWindow appears.
Everything goes fine until I press back in popupWindow and get back to activity and click on the Button again. Everything freezes and the application stops.



My popupWindow has customized view. Its view consists of a SearchView, ExpandableListView, and a Button to submit. The expandableListView retrieves Phone contacts.
I searched for the problem, but they had problems with dismissing on back pressed, which is not what I'm dealing with.



Button import_contact = findViewById(R.id.import_contact);
import_contact.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
LayoutInflater inflater = (LayoutInflater)
getSystemService(LAYOUT_INFLATER_SERVICE);
View popupView = inflater.inflate(R.layout.import_contacts_window, null);
int width = LinearLayout.LayoutParams.MATCH_PARENT;
int height = LinearLayout.LayoutParams.MATCH_PARENT;
PopupWindow popupWindow = new PopupWindow(popupView, width, height, true);
popupWindow.setOutsideTouchable(true);
popupWindow.setBackgroundDrawable(new ColorDrawable(Color.GRAY));
popupWindow.setContentView(popupView);
popupWindow.showAtLocation(findViewById(R.id.contacts_container), Gravity.CENTER, 0, 0);
popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
@Override
public void onDismiss() {
Log.e("dismiss", "true");
}
});

contactsListView = popupView.findViewById(R.id.phone_contacts_list);
contactsListDataAdapter = new ContactListAdapter(MainActivity.this,
expandableListTitle,
expandableListDetail);
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
int w = metrics.widthPixels;
contactsListView.setIndicatorBounds(w - 30, w - 6);
contactsListView.setAdapter(contactsListDataAdapter);
SearchManager searchManager = (SearchManager)
getSystemService(Context.SEARCH_SERVICE);
search = popupView.findViewById(R.id.searchContacts);
search.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
search.setIconifiedByDefault(false);
search.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
Log.e("onQueryTextSubmit", "1");
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
Log.e("onQueryTextChange", " ");
contactsListDataAdapter.filterData(newText);
expandAll();
return true;
}
});
search.setOnCloseListener(new SearchView.OnCloseListener() {
@Override
public boolean onClose() {
Log.e("onClose", " ");
return false;
}
});
Button OK = popupView.findViewById(R.id.OK);
OK.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO: verify OK from Client with a popup dialog
}
});
if (!hasPhoneContactsPermission(Manifest.permission.READ_CONTACTS)) {
requestPermission(Manifest.permission.READ_CONTACTS, PERMISSION_REQUEST_CODE_READ_CONTACTS);
} else {
readPhoneContacts();
}
}
});


Here is the log after popupwindow dismissed and after I pressed on the button to reopen the popupWindow:



12-27 03:57:31.925 16287-16287/com.ghasedakia E/dismiss: true
12-27 03:57:31.925 16287-16287/com.ghasedakia W/InputEventReceiver:
Attempted to finish an input event but the input event receiver has already
been disposed.
12-27 03:57:50.765 151-179/? W/AudioPolicyManagerBase: getOutput() could not
find output for stream 1, samplingRate 0,format 0, channels 3, flags 0
12-27 03:57:50.765 151-151/? W/AudioPolicyManagerBase: getOutput() could not
find output for stream 1, samplingRate 0,format 0, channels 3, flags 0
12-27 03:57:50.765 151-11050/? W/AudioPolicyManagerBase: getOutput() could
not find output for stream 1, samplingRate 44100,format 1, channels 1, flags
4
12-27 03:57:50.765 313-426/system_process E/AudioTrack: Could not get audio
output for stream type 1
12-27 03:57:50.765 313-426/system_process E/SoundPool: Error creating
AudioTrack
12-27 03:57:50.905 493-496/com.android.phone D/dalvikvm: GC_CONCURRENT freed
384K, 6% free 11238K/11847K, paused 0ms+0ms, total 2ms


After some time passed, the application crashed with the following log:



12-27 04:34:12.977 313-392/system_process I/InputDispatcher: Application is 
not responding: Window{53799ea0 com.ghasedakia/com.ghasedakia.MainActivity
paused=false}. It has been 5003.3ms since event, 5003.3ms since wait started.
Reason: Waiting because the touched window has not finished processing the input
events that were previously delivered to it.
12-27 04:34:12.977 313-392/system_process I/WindowManager: Input event
dispatching timed out sending to com.ghasedakia/com.ghasedakia.MainActivity
12-27 04:34:12.981 313-392/system_process I/Process: Sending signal. PID: 16861
SIG: 3
12-27 04:34:12.989 16861-16866/com.ghasedakia I/dalvikvm: threadid=3: reacting
to signal 3
12-27 04:34:12.989 313-316/system_process D/dalvikvm: GC_CONCURRENT freed 784K,
15% free 13983K/16391K, paused 1ms+1ms, total 10ms
12-27 04:34:13.001 16861-16866/com.ghasedakia I/dalvikvm: Wrote stack traces to
'/data/anr/traces.txt'
12-27 04:34:13.005 313-392/system_process I/Process: Sending signal. PID: 313
SIG: 3
12-27 04:34:13.005 313-318/system_process I/dalvikvm: threadid=3: reacting to
signal 3
12-27 04:34:13.077 313-325/system_process E/Sensors: Select fail, disconnect all
clients (errno=4)
12-27 04:34:13.089 313-318/system_process I/dalvikvm: Wrote stack traces to
'/data/anr/traces.txt'
12-27 04:34:13.113 313-392/system_process I/Process: Sending signal. PID: 493
SIG: 3
12-27 04:34:13.113 493-500/com.android.phone I/dalvikvm: threadid=3: reacting to
signal 3
12-27 04:34:13.113 313-316/system_process D/dalvikvm: GC_CONCURRENT freed 42K,
15% free 13941K/16391K, paused 11ms+11ms, total 26ms
12-27 04:34:13.141 493-500/com.android.phone I/dalvikvm: Wrote stack traces to
'/data/anr/traces.txt'
12-27 04:34:13.141 313-392/system_process I/Process: Sending signal. PID: 432
SIG: 3
12-27 04:34:13.141 432-437/com.android.systemui I/dalvikvm: threadid=3: reacting
to signal 3
12-27 04:34:13.153 432-437/com.android.systemui I/dalvikvm: Wrote stack traces
to '/data/anr/traces.txt'
12-27 04:34:13.201 313-316/system_process D/dalvikvm: GC_CONCURRENT freed 521K,
14% free 14148K/16391K, paused 12ms+1ms, total 24ms
12-27 04:34:13.201 313-392/system_process D/dalvikvm: WAIT_FOR_CONCURRENT_GC
blocked 12ms
12-27 04:34:13.205 313-392/system_process D/dalvikvm: GC_EXPLICIT freed 17K, 14%
free 14131K/16391K, paused 0ms+1ms, total 8ms
12-27 04:34:13.713 313-392/system_process E/ActivityManager: ANR in
com.ghasedakia (com.ghasedakia/.MainActivity)
Reason: keyDispatchingTimedOut
Load: 0.69 / 0.34 / 0.45
CPU usage from 7981ms to 0ms ago:
99% 16861/com.ghasedakia: 99% user + 0% kernel
100% TOTAL: 99% user + 0.2% kernel
CPU usage from 227ms to 731ms later:
94% 16861/com.ghasedakia: 94% user + 0% kernel
94% 16861/com.ghasedakia: 94% user + 0% kernel
100% TOTAL: 100% user + 0% kernel
12-27 04:34:13.749 313-316/system_process D/dalvikvm: GC_CONCURRENT freed 412K,
12% free 14568K/16391K, paused 12ms+1ms, total 27ms
12-27 04:34:13.749 313-16887/system_process D/dalvikvm: WAIT_FOR_CONCURRENT_GC
blocked 16ms
12-27 04:34:13.757 313-16887/system_process D/dalvikvm: GC_FOR_ALLOC freed 459K,
13% free 14275K/16391K, paused 9ms, total 9ms
12-27 04:34:16.081 313-325/system_process D/Sensors: Client connection accepted
(232)


I saw this page,
https://blog.csdn.net/geekqian/article/details/70279076



I think the problem is the same as me. But I cant setFocusable to false because I need to handle clicks on my popupWindow.



I expect that each time a click on the Button occurs, the popupWindow be shown. But the second time I touch the Button, the application freezes. Any ideas where the problem is?










share|improve this question
























  • When you say 'Everything freezes and the application stops', you must get an error in the error log. Can you share that.
    – Nero
    Dec 27 '18 at 21:01










  • override onBackPressed() and call popUpWindow.dismiss() if it work's i will post it as an answer with explanation. :D
    – Anmol
    Dec 28 '18 at 5:31












  • @Anmol I checked. When I press back on popupWindow, it doesn't trigger onBackPressed in my Activity. And popupWindow dismisses. I checked it with a Log.e in the first of onDissmissListener and onBackPressed overridden.
    – Nahid Ataei
    Dec 28 '18 at 5:59












  • @Nero I added the log after I press the Button in my question, but nothing helpful I think.
    – Nahid Ataei
    Dec 28 '18 at 6:03










  • @NahidAtaei Add popUpWindow.dismiss() right before log.e("dismiss","true") as suggested and try again.
    – kowie le roux
    Dec 28 '18 at 6:11














0












0








0







I have an Activity in my android project.
With a click on a Button, a popupWindow appears.
Everything goes fine until I press back in popupWindow and get back to activity and click on the Button again. Everything freezes and the application stops.



My popupWindow has customized view. Its view consists of a SearchView, ExpandableListView, and a Button to submit. The expandableListView retrieves Phone contacts.
I searched for the problem, but they had problems with dismissing on back pressed, which is not what I'm dealing with.



Button import_contact = findViewById(R.id.import_contact);
import_contact.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
LayoutInflater inflater = (LayoutInflater)
getSystemService(LAYOUT_INFLATER_SERVICE);
View popupView = inflater.inflate(R.layout.import_contacts_window, null);
int width = LinearLayout.LayoutParams.MATCH_PARENT;
int height = LinearLayout.LayoutParams.MATCH_PARENT;
PopupWindow popupWindow = new PopupWindow(popupView, width, height, true);
popupWindow.setOutsideTouchable(true);
popupWindow.setBackgroundDrawable(new ColorDrawable(Color.GRAY));
popupWindow.setContentView(popupView);
popupWindow.showAtLocation(findViewById(R.id.contacts_container), Gravity.CENTER, 0, 0);
popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
@Override
public void onDismiss() {
Log.e("dismiss", "true");
}
});

contactsListView = popupView.findViewById(R.id.phone_contacts_list);
contactsListDataAdapter = new ContactListAdapter(MainActivity.this,
expandableListTitle,
expandableListDetail);
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
int w = metrics.widthPixels;
contactsListView.setIndicatorBounds(w - 30, w - 6);
contactsListView.setAdapter(contactsListDataAdapter);
SearchManager searchManager = (SearchManager)
getSystemService(Context.SEARCH_SERVICE);
search = popupView.findViewById(R.id.searchContacts);
search.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
search.setIconifiedByDefault(false);
search.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
Log.e("onQueryTextSubmit", "1");
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
Log.e("onQueryTextChange", " ");
contactsListDataAdapter.filterData(newText);
expandAll();
return true;
}
});
search.setOnCloseListener(new SearchView.OnCloseListener() {
@Override
public boolean onClose() {
Log.e("onClose", " ");
return false;
}
});
Button OK = popupView.findViewById(R.id.OK);
OK.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO: verify OK from Client with a popup dialog
}
});
if (!hasPhoneContactsPermission(Manifest.permission.READ_CONTACTS)) {
requestPermission(Manifest.permission.READ_CONTACTS, PERMISSION_REQUEST_CODE_READ_CONTACTS);
} else {
readPhoneContacts();
}
}
});


Here is the log after popupwindow dismissed and after I pressed on the button to reopen the popupWindow:



12-27 03:57:31.925 16287-16287/com.ghasedakia E/dismiss: true
12-27 03:57:31.925 16287-16287/com.ghasedakia W/InputEventReceiver:
Attempted to finish an input event but the input event receiver has already
been disposed.
12-27 03:57:50.765 151-179/? W/AudioPolicyManagerBase: getOutput() could not
find output for stream 1, samplingRate 0,format 0, channels 3, flags 0
12-27 03:57:50.765 151-151/? W/AudioPolicyManagerBase: getOutput() could not
find output for stream 1, samplingRate 0,format 0, channels 3, flags 0
12-27 03:57:50.765 151-11050/? W/AudioPolicyManagerBase: getOutput() could
not find output for stream 1, samplingRate 44100,format 1, channels 1, flags
4
12-27 03:57:50.765 313-426/system_process E/AudioTrack: Could not get audio
output for stream type 1
12-27 03:57:50.765 313-426/system_process E/SoundPool: Error creating
AudioTrack
12-27 03:57:50.905 493-496/com.android.phone D/dalvikvm: GC_CONCURRENT freed
384K, 6% free 11238K/11847K, paused 0ms+0ms, total 2ms


After some time passed, the application crashed with the following log:



12-27 04:34:12.977 313-392/system_process I/InputDispatcher: Application is 
not responding: Window{53799ea0 com.ghasedakia/com.ghasedakia.MainActivity
paused=false}. It has been 5003.3ms since event, 5003.3ms since wait started.
Reason: Waiting because the touched window has not finished processing the input
events that were previously delivered to it.
12-27 04:34:12.977 313-392/system_process I/WindowManager: Input event
dispatching timed out sending to com.ghasedakia/com.ghasedakia.MainActivity
12-27 04:34:12.981 313-392/system_process I/Process: Sending signal. PID: 16861
SIG: 3
12-27 04:34:12.989 16861-16866/com.ghasedakia I/dalvikvm: threadid=3: reacting
to signal 3
12-27 04:34:12.989 313-316/system_process D/dalvikvm: GC_CONCURRENT freed 784K,
15% free 13983K/16391K, paused 1ms+1ms, total 10ms
12-27 04:34:13.001 16861-16866/com.ghasedakia I/dalvikvm: Wrote stack traces to
'/data/anr/traces.txt'
12-27 04:34:13.005 313-392/system_process I/Process: Sending signal. PID: 313
SIG: 3
12-27 04:34:13.005 313-318/system_process I/dalvikvm: threadid=3: reacting to
signal 3
12-27 04:34:13.077 313-325/system_process E/Sensors: Select fail, disconnect all
clients (errno=4)
12-27 04:34:13.089 313-318/system_process I/dalvikvm: Wrote stack traces to
'/data/anr/traces.txt'
12-27 04:34:13.113 313-392/system_process I/Process: Sending signal. PID: 493
SIG: 3
12-27 04:34:13.113 493-500/com.android.phone I/dalvikvm: threadid=3: reacting to
signal 3
12-27 04:34:13.113 313-316/system_process D/dalvikvm: GC_CONCURRENT freed 42K,
15% free 13941K/16391K, paused 11ms+11ms, total 26ms
12-27 04:34:13.141 493-500/com.android.phone I/dalvikvm: Wrote stack traces to
'/data/anr/traces.txt'
12-27 04:34:13.141 313-392/system_process I/Process: Sending signal. PID: 432
SIG: 3
12-27 04:34:13.141 432-437/com.android.systemui I/dalvikvm: threadid=3: reacting
to signal 3
12-27 04:34:13.153 432-437/com.android.systemui I/dalvikvm: Wrote stack traces
to '/data/anr/traces.txt'
12-27 04:34:13.201 313-316/system_process D/dalvikvm: GC_CONCURRENT freed 521K,
14% free 14148K/16391K, paused 12ms+1ms, total 24ms
12-27 04:34:13.201 313-392/system_process D/dalvikvm: WAIT_FOR_CONCURRENT_GC
blocked 12ms
12-27 04:34:13.205 313-392/system_process D/dalvikvm: GC_EXPLICIT freed 17K, 14%
free 14131K/16391K, paused 0ms+1ms, total 8ms
12-27 04:34:13.713 313-392/system_process E/ActivityManager: ANR in
com.ghasedakia (com.ghasedakia/.MainActivity)
Reason: keyDispatchingTimedOut
Load: 0.69 / 0.34 / 0.45
CPU usage from 7981ms to 0ms ago:
99% 16861/com.ghasedakia: 99% user + 0% kernel
100% TOTAL: 99% user + 0.2% kernel
CPU usage from 227ms to 731ms later:
94% 16861/com.ghasedakia: 94% user + 0% kernel
94% 16861/com.ghasedakia: 94% user + 0% kernel
100% TOTAL: 100% user + 0% kernel
12-27 04:34:13.749 313-316/system_process D/dalvikvm: GC_CONCURRENT freed 412K,
12% free 14568K/16391K, paused 12ms+1ms, total 27ms
12-27 04:34:13.749 313-16887/system_process D/dalvikvm: WAIT_FOR_CONCURRENT_GC
blocked 16ms
12-27 04:34:13.757 313-16887/system_process D/dalvikvm: GC_FOR_ALLOC freed 459K,
13% free 14275K/16391K, paused 9ms, total 9ms
12-27 04:34:16.081 313-325/system_process D/Sensors: Client connection accepted
(232)


I saw this page,
https://blog.csdn.net/geekqian/article/details/70279076



I think the problem is the same as me. But I cant setFocusable to false because I need to handle clicks on my popupWindow.



I expect that each time a click on the Button occurs, the popupWindow be shown. But the second time I touch the Button, the application freezes. Any ideas where the problem is?










share|improve this question















I have an Activity in my android project.
With a click on a Button, a popupWindow appears.
Everything goes fine until I press back in popupWindow and get back to activity and click on the Button again. Everything freezes and the application stops.



My popupWindow has customized view. Its view consists of a SearchView, ExpandableListView, and a Button to submit. The expandableListView retrieves Phone contacts.
I searched for the problem, but they had problems with dismissing on back pressed, which is not what I'm dealing with.



Button import_contact = findViewById(R.id.import_contact);
import_contact.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
LayoutInflater inflater = (LayoutInflater)
getSystemService(LAYOUT_INFLATER_SERVICE);
View popupView = inflater.inflate(R.layout.import_contacts_window, null);
int width = LinearLayout.LayoutParams.MATCH_PARENT;
int height = LinearLayout.LayoutParams.MATCH_PARENT;
PopupWindow popupWindow = new PopupWindow(popupView, width, height, true);
popupWindow.setOutsideTouchable(true);
popupWindow.setBackgroundDrawable(new ColorDrawable(Color.GRAY));
popupWindow.setContentView(popupView);
popupWindow.showAtLocation(findViewById(R.id.contacts_container), Gravity.CENTER, 0, 0);
popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
@Override
public void onDismiss() {
Log.e("dismiss", "true");
}
});

contactsListView = popupView.findViewById(R.id.phone_contacts_list);
contactsListDataAdapter = new ContactListAdapter(MainActivity.this,
expandableListTitle,
expandableListDetail);
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
int w = metrics.widthPixels;
contactsListView.setIndicatorBounds(w - 30, w - 6);
contactsListView.setAdapter(contactsListDataAdapter);
SearchManager searchManager = (SearchManager)
getSystemService(Context.SEARCH_SERVICE);
search = popupView.findViewById(R.id.searchContacts);
search.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
search.setIconifiedByDefault(false);
search.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
Log.e("onQueryTextSubmit", "1");
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
Log.e("onQueryTextChange", " ");
contactsListDataAdapter.filterData(newText);
expandAll();
return true;
}
});
search.setOnCloseListener(new SearchView.OnCloseListener() {
@Override
public boolean onClose() {
Log.e("onClose", " ");
return false;
}
});
Button OK = popupView.findViewById(R.id.OK);
OK.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO: verify OK from Client with a popup dialog
}
});
if (!hasPhoneContactsPermission(Manifest.permission.READ_CONTACTS)) {
requestPermission(Manifest.permission.READ_CONTACTS, PERMISSION_REQUEST_CODE_READ_CONTACTS);
} else {
readPhoneContacts();
}
}
});


Here is the log after popupwindow dismissed and after I pressed on the button to reopen the popupWindow:



12-27 03:57:31.925 16287-16287/com.ghasedakia E/dismiss: true
12-27 03:57:31.925 16287-16287/com.ghasedakia W/InputEventReceiver:
Attempted to finish an input event but the input event receiver has already
been disposed.
12-27 03:57:50.765 151-179/? W/AudioPolicyManagerBase: getOutput() could not
find output for stream 1, samplingRate 0,format 0, channels 3, flags 0
12-27 03:57:50.765 151-151/? W/AudioPolicyManagerBase: getOutput() could not
find output for stream 1, samplingRate 0,format 0, channels 3, flags 0
12-27 03:57:50.765 151-11050/? W/AudioPolicyManagerBase: getOutput() could
not find output for stream 1, samplingRate 44100,format 1, channels 1, flags
4
12-27 03:57:50.765 313-426/system_process E/AudioTrack: Could not get audio
output for stream type 1
12-27 03:57:50.765 313-426/system_process E/SoundPool: Error creating
AudioTrack
12-27 03:57:50.905 493-496/com.android.phone D/dalvikvm: GC_CONCURRENT freed
384K, 6% free 11238K/11847K, paused 0ms+0ms, total 2ms


After some time passed, the application crashed with the following log:



12-27 04:34:12.977 313-392/system_process I/InputDispatcher: Application is 
not responding: Window{53799ea0 com.ghasedakia/com.ghasedakia.MainActivity
paused=false}. It has been 5003.3ms since event, 5003.3ms since wait started.
Reason: Waiting because the touched window has not finished processing the input
events that were previously delivered to it.
12-27 04:34:12.977 313-392/system_process I/WindowManager: Input event
dispatching timed out sending to com.ghasedakia/com.ghasedakia.MainActivity
12-27 04:34:12.981 313-392/system_process I/Process: Sending signal. PID: 16861
SIG: 3
12-27 04:34:12.989 16861-16866/com.ghasedakia I/dalvikvm: threadid=3: reacting
to signal 3
12-27 04:34:12.989 313-316/system_process D/dalvikvm: GC_CONCURRENT freed 784K,
15% free 13983K/16391K, paused 1ms+1ms, total 10ms
12-27 04:34:13.001 16861-16866/com.ghasedakia I/dalvikvm: Wrote stack traces to
'/data/anr/traces.txt'
12-27 04:34:13.005 313-392/system_process I/Process: Sending signal. PID: 313
SIG: 3
12-27 04:34:13.005 313-318/system_process I/dalvikvm: threadid=3: reacting to
signal 3
12-27 04:34:13.077 313-325/system_process E/Sensors: Select fail, disconnect all
clients (errno=4)
12-27 04:34:13.089 313-318/system_process I/dalvikvm: Wrote stack traces to
'/data/anr/traces.txt'
12-27 04:34:13.113 313-392/system_process I/Process: Sending signal. PID: 493
SIG: 3
12-27 04:34:13.113 493-500/com.android.phone I/dalvikvm: threadid=3: reacting to
signal 3
12-27 04:34:13.113 313-316/system_process D/dalvikvm: GC_CONCURRENT freed 42K,
15% free 13941K/16391K, paused 11ms+11ms, total 26ms
12-27 04:34:13.141 493-500/com.android.phone I/dalvikvm: Wrote stack traces to
'/data/anr/traces.txt'
12-27 04:34:13.141 313-392/system_process I/Process: Sending signal. PID: 432
SIG: 3
12-27 04:34:13.141 432-437/com.android.systemui I/dalvikvm: threadid=3: reacting
to signal 3
12-27 04:34:13.153 432-437/com.android.systemui I/dalvikvm: Wrote stack traces
to '/data/anr/traces.txt'
12-27 04:34:13.201 313-316/system_process D/dalvikvm: GC_CONCURRENT freed 521K,
14% free 14148K/16391K, paused 12ms+1ms, total 24ms
12-27 04:34:13.201 313-392/system_process D/dalvikvm: WAIT_FOR_CONCURRENT_GC
blocked 12ms
12-27 04:34:13.205 313-392/system_process D/dalvikvm: GC_EXPLICIT freed 17K, 14%
free 14131K/16391K, paused 0ms+1ms, total 8ms
12-27 04:34:13.713 313-392/system_process E/ActivityManager: ANR in
com.ghasedakia (com.ghasedakia/.MainActivity)
Reason: keyDispatchingTimedOut
Load: 0.69 / 0.34 / 0.45
CPU usage from 7981ms to 0ms ago:
99% 16861/com.ghasedakia: 99% user + 0% kernel
100% TOTAL: 99% user + 0.2% kernel
CPU usage from 227ms to 731ms later:
94% 16861/com.ghasedakia: 94% user + 0% kernel
94% 16861/com.ghasedakia: 94% user + 0% kernel
100% TOTAL: 100% user + 0% kernel
12-27 04:34:13.749 313-316/system_process D/dalvikvm: GC_CONCURRENT freed 412K,
12% free 14568K/16391K, paused 12ms+1ms, total 27ms
12-27 04:34:13.749 313-16887/system_process D/dalvikvm: WAIT_FOR_CONCURRENT_GC
blocked 16ms
12-27 04:34:13.757 313-16887/system_process D/dalvikvm: GC_FOR_ALLOC freed 459K,
13% free 14275K/16391K, paused 9ms, total 9ms
12-27 04:34:16.081 313-325/system_process D/Sensors: Client connection accepted
(232)


I saw this page,
https://blog.csdn.net/geekqian/article/details/70279076



I think the problem is the same as me. But I cant setFocusable to false because I need to handle clicks on my popupWindow.



I expect that each time a click on the Button occurs, the popupWindow be shown. But the second time I touch the Button, the application freezes. Any ideas where the problem is?







android popupwindow dismiss onbackpressed






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 28 '18 at 6:44

























asked Dec 27 '18 at 19:57









Nahid Ataei

2517




2517












  • When you say 'Everything freezes and the application stops', you must get an error in the error log. Can you share that.
    – Nero
    Dec 27 '18 at 21:01










  • override onBackPressed() and call popUpWindow.dismiss() if it work's i will post it as an answer with explanation. :D
    – Anmol
    Dec 28 '18 at 5:31












  • @Anmol I checked. When I press back on popupWindow, it doesn't trigger onBackPressed in my Activity. And popupWindow dismisses. I checked it with a Log.e in the first of onDissmissListener and onBackPressed overridden.
    – Nahid Ataei
    Dec 28 '18 at 5:59












  • @Nero I added the log after I press the Button in my question, but nothing helpful I think.
    – Nahid Ataei
    Dec 28 '18 at 6:03










  • @NahidAtaei Add popUpWindow.dismiss() right before log.e("dismiss","true") as suggested and try again.
    – kowie le roux
    Dec 28 '18 at 6:11


















  • When you say 'Everything freezes and the application stops', you must get an error in the error log. Can you share that.
    – Nero
    Dec 27 '18 at 21:01










  • override onBackPressed() and call popUpWindow.dismiss() if it work's i will post it as an answer with explanation. :D
    – Anmol
    Dec 28 '18 at 5:31












  • @Anmol I checked. When I press back on popupWindow, it doesn't trigger onBackPressed in my Activity. And popupWindow dismisses. I checked it with a Log.e in the first of onDissmissListener and onBackPressed overridden.
    – Nahid Ataei
    Dec 28 '18 at 5:59












  • @Nero I added the log after I press the Button in my question, but nothing helpful I think.
    – Nahid Ataei
    Dec 28 '18 at 6:03










  • @NahidAtaei Add popUpWindow.dismiss() right before log.e("dismiss","true") as suggested and try again.
    – kowie le roux
    Dec 28 '18 at 6:11
















When you say 'Everything freezes and the application stops', you must get an error in the error log. Can you share that.
– Nero
Dec 27 '18 at 21:01




When you say 'Everything freezes and the application stops', you must get an error in the error log. Can you share that.
– Nero
Dec 27 '18 at 21:01












override onBackPressed() and call popUpWindow.dismiss() if it work's i will post it as an answer with explanation. :D
– Anmol
Dec 28 '18 at 5:31






override onBackPressed() and call popUpWindow.dismiss() if it work's i will post it as an answer with explanation. :D
– Anmol
Dec 28 '18 at 5:31














@Anmol I checked. When I press back on popupWindow, it doesn't trigger onBackPressed in my Activity. And popupWindow dismisses. I checked it with a Log.e in the first of onDissmissListener and onBackPressed overridden.
– Nahid Ataei
Dec 28 '18 at 5:59






@Anmol I checked. When I press back on popupWindow, it doesn't trigger onBackPressed in my Activity. And popupWindow dismisses. I checked it with a Log.e in the first of onDissmissListener and onBackPressed overridden.
– Nahid Ataei
Dec 28 '18 at 5:59














@Nero I added the log after I press the Button in my question, but nothing helpful I think.
– Nahid Ataei
Dec 28 '18 at 6:03




@Nero I added the log after I press the Button in my question, but nothing helpful I think.
– Nahid Ataei
Dec 28 '18 at 6:03












@NahidAtaei Add popUpWindow.dismiss() right before log.e("dismiss","true") as suggested and try again.
– kowie le roux
Dec 28 '18 at 6:11




@NahidAtaei Add popUpWindow.dismiss() right before log.e("dismiss","true") as suggested and try again.
– kowie le roux
Dec 28 '18 at 6:11












1 Answer
1






active

oldest

votes


















0














I couldn't find any solution. I used another activity instead of popupWindow. I don't like it but that's the solution by now.






share|improve this answer





















  • post your solution so others with the same issue can use the work-around
    – kowie le roux
    Dec 28 '18 at 19:06











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53950238%2fcan-popupwindow-in-android-be-shown-again-after-one-dismiss-i-cant-do-it%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














I couldn't find any solution. I used another activity instead of popupWindow. I don't like it but that's the solution by now.






share|improve this answer





















  • post your solution so others with the same issue can use the work-around
    – kowie le roux
    Dec 28 '18 at 19:06
















0














I couldn't find any solution. I used another activity instead of popupWindow. I don't like it but that's the solution by now.






share|improve this answer





















  • post your solution so others with the same issue can use the work-around
    – kowie le roux
    Dec 28 '18 at 19:06














0












0








0






I couldn't find any solution. I used another activity instead of popupWindow. I don't like it but that's the solution by now.






share|improve this answer












I couldn't find any solution. I used another activity instead of popupWindow. I don't like it but that's the solution by now.







share|improve this answer












share|improve this answer



share|improve this answer










answered Dec 28 '18 at 12:32









Nahid Ataei

2517




2517












  • post your solution so others with the same issue can use the work-around
    – kowie le roux
    Dec 28 '18 at 19:06


















  • post your solution so others with the same issue can use the work-around
    – kowie le roux
    Dec 28 '18 at 19:06
















post your solution so others with the same issue can use the work-around
– kowie le roux
Dec 28 '18 at 19:06




post your solution so others with the same issue can use the work-around
– kowie le roux
Dec 28 '18 at 19:06


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53950238%2fcan-popupwindow-in-android-be-shown-again-after-one-dismiss-i-cant-do-it%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Monofisismo

Angular Downloading a file using contenturl with Basic Authentication

Olmecas