Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/189.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/firebase/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 使用异步任务在实时Firebase中提交大量值?_Android_Firebase_Firebase Realtime Database - Fatal编程技术网

Android 使用异步任务在实时Firebase中提交大量值?

Android 使用异步任务在实时Firebase中提交大量值?,android,firebase,firebase-realtime-database,Android,Firebase,Firebase Realtime Database,提交大量值(如“2000”)时是否需要使用异步任务实时Firebase数据库的值与否?移动客户端的Firebase API在读写数据时都是异步的,因此您不需要在AsyncTask中执行,在提交大量值(如“2000”)时是否需要使用async task 是 Firebase API使用manithread以完整的方式使用,因此,如果您有大量数据和图像,那么您的cpu将占用更多的时间,从而使您的ui冻结…因此,为了避免这种情况,您需要使用后台线程 示例 class Myuploadtask ext

提交大量值(如“2000”)时是否需要使用异步任务实时Firebase数据库的值与否?

移动客户端的Firebase API在读写数据时都是异步的,因此您不需要在
AsyncTask

中执行,在提交大量值(如“2000”)时是否需要使用async task

Firebase API使用manithread以完整的方式使用,因此,如果您有大量数据和图像,那么您的cpu将占用更多的时间,从而使您的ui冻结…因此,为了避免这种情况,您需要使用后台线程

示例

class Myuploadtask  extends AsyncTask<String,String,String>{

        @Override
        protected String doInBackground(String... strings) {


                upload_5Images();  //call here

            return null;
        }

    }

    private  void upload_5Images(){
        //do you upload functions
    }
类Myuploadtask扩展了AsyncTask{ @凌驾 受保护的字符串背景(字符串…字符串){ 上传_5Images();//在此处调用 返回null; } } 私有void上传_5Images(){ //你上传功能吗 } 注意:我面临着同样的问题,比如上传大量数据时,我的progressdialog在使用后台线程时被击中 解决了。所以我的建议,如果你拥抱数据上传更好地使用 背景线程