android-asynctask

Async task could not keep up with for loop (firebase)

大憨熊 提交于 2021-01-28 12:13:14
问题 for (Uri mUri : mSelected) { imagesRef = storageRef.child(postid + mUri.getLastPathSegment()); imagesRef.putFile(mUri).addOnSuccessListener(task4 -> db.collection("posts").document(postid).update("photo_id", FieldValue.arrayUnion(imagesRef.getDownloadUrl()))); } So, now i am working with firestore and firebase storage. I uploaded (multiple) images to the storage, and when it is uploaded, i get the download url and wants to add it into my firestore. So, the problem is, only the last image is

Espresso test blocked with background thread. Application not idle Exception: “AppNotIdleException.”

北战南征 提交于 2021-01-27 11:28:05
问题 My android espresso unit test blocked due to some background thread not idle. How can i figure out which thread is blocking my application to execute? android.support.test.espresso.AppNotIdleException: Looped for 246 iterations over 60 SECONDS. The following Idle Conditions failed ASYNC_TASKS_HAVE_IDLED. at dalvik.system.VMStack.getThreadStackTrace(Native Method) at java.lang.Thread.getStackTrace(Thread.java:580) at android.support.test.espresso.base.DefaultFailureHandler.getUserFriendlyError

Espresso test blocked with background thread. Application not idle Exception: “AppNotIdleException.”

谁说胖子不能爱 提交于 2021-01-27 11:26:42
问题 My android espresso unit test blocked due to some background thread not idle. How can i figure out which thread is blocking my application to execute? android.support.test.espresso.AppNotIdleException: Looped for 246 iterations over 60 SECONDS. The following Idle Conditions failed ASYNC_TASKS_HAVE_IDLED. at dalvik.system.VMStack.getThreadStackTrace(Native Method) at java.lang.Thread.getStackTrace(Thread.java:580) at android.support.test.espresso.base.DefaultFailureHandler.getUserFriendlyError

Correct context to use within callbacks

十年热恋 提交于 2020-12-05 04:56:17
问题 The title pretty much says it all. If you have a callback from one class to another and need to call some method from within the callback that requires a context what is the correct context to use? A common example would be an AsyncTask with a callback to the Activity or Fragment that used it. I generally try to avoid using getApplicationContext() but I cannot use this as the context from within a callback. Is this a case where using a broader context is appropriate? To clarify further I'm

Correct context to use within callbacks

二次信任 提交于 2020-12-05 04:55:10
问题 The title pretty much says it all. If you have a callback from one class to another and need to call some method from within the callback that requires a context what is the correct context to use? A common example would be an AsyncTask with a callback to the Activity or Fragment that used it. I generally try to avoid using getApplicationContext() but I cannot use this as the context from within a callback. Is this a case where using a broader context is appropriate? To clarify further I'm

get current Date from internet in android

六月ゝ 毕业季﹏ 提交于 2020-05-28 07:36:05
问题 I want to know if there is any API/class in android which can give us the original date as I do not want to get the date/time from android device. 回答1: Updated!! The old answer does not work because the timeapi.org is down. Here is the my new getTime method. It's using JSOUP . private long getTime() throws Exception { String url = "https://time.is/Unix_time_now"; Document doc = Jsoup.parse(new URL(url).openStream(), "UTF-8", url); String[] tags = new String[] { "div[id=time_section]", "div[id