简体   繁体   English

加载soundpool时,活动屏幕变为空白

[英]Activity screen goes blank while loading soundpools

I am loading around 100 soundpools of small sound which I need them through out application in an activity. 我正在加载大约100个声音小的声音池,我需要它们通过活动中的应用程序。 When this activity starts, the screen goes blank and the background loads after loading all soundpools. 当此活动开始时,屏幕变为空白,并在加载所有soundpool后加载背景。

How do make it display the background I which have already added in xml through out while loading soundpools? 如何在加载soundpool时显示已经在xml中添加的背景?

Use AsyncTask to handle this. 使用AsyncTask来处理这个问题。

private class MyBackgroundTask extends AsyncTask<String, Void, Boolean> {

    @Override
    protected void onPreExecute() {
        //initialize views like progress dialog.
    }

    @Override
    protected Boolean doInBackground(String... params) {
        //Add code which you want to run in background.
        //In your case, code to load sound pools
    }

    @Override
    public void onPostExecute(Boolean success) {
        //update UI with the result
    }
}

And in onCreate method, 在onCreate方法中,

new MyBackgroundTask().execute();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM