I am making a music player application on android. My Launcher Activity(MainActivity.java)
displays all the songs in a Custom ListView
. My app was running perfectly and then I decided to add a SearchView
widget in the ToolBar
.
Now when I type a query in the SearchView
, me Searchable.java
activity opens up and after 2-3 sconds the whole screen turns black. The search results are shown for a brief time but the black screen stays there permanently.
If don't use the search option then the application shows no such behavior.
Android: Black Screen appears on the screen when search operation is performed by android SearchView
Asked
Active
Viewed 420 times
-3

Community
- 1
- 1

Prakhar Singh
- 79
- 12
-
Please mention the reasons for the negative votes. It may prove to be helpful. – Prakhar Singh Jan 20 '17 at 04:50
-
2you should post your code where you getting problem. Without your code it is very difficult to detect where is problem. – Saurabh Bhandari Jan 20 '17 at 05:08
1 Answers
1
Your app displaying black screen because you are doing search operations on your main thread , that's why your main thread hanging , check your log monitor you will get error like , too much work on main thread , for overcome this issue you need to perform your search operations on another thread or in background and update your view when search completed , you can use Asynctask for background task .

Rajesh Koshti
- 572
- 1
- 7
- 25
-
-
just put your search query for getting audio data list in asynctask it will handle automatically all the things check this out for more details https://developer.android.com/reference/android/os/AsyncTask.html – Rajesh Koshti Jan 20 '17 at 09:12
-
So i was reading the link and I wanted to ask that since the operation to be performed is Searching, should I place the execute() method call inside onCreateOptionsMenu() method? – Prakhar Singh Jan 20 '17 at 16:08