android-asynctask

Support lib LruCache throws NullPointerException: key == null || value == null for some reason

谁都会走 提交于 2020-01-07 08:00:35
问题 I've been trying to understand how to use the LruCache to combat the problem of outOfMemory errors in the lower APIs however I've been having trouble implementing it correctly. For some reason when I try to put a Drawable and url string in cache as an identifier the system throws a nullpointerexception: Key == null || value == null error which is a new kind of error to me. I have searched around the internet but it seems no one else has had this kind of error. Any Ideas on what is going wrong

How to update Fragment TextView from FragmentActivity when finish a AsyncTask

浪尽此生 提交于 2020-01-07 07:59:07
问题 I have an activity extends from FragmentActivity , and I have four TABS of Fragments , I have AsyncTask in main FragmentActivity to get load data from a server, so, I want to update each Fragment data when complete the AsyncTask function on parent FragmentActivity, since I'm using android.support.v4.view.ViewPager all the Fragment's UI loading when starts the Activity with blank data, so, I want to update the each fragment fields (TextView) with the data getting from AsyncTask, How I can

App crashes on received gcm message when it's closed

可紊 提交于 2020-01-07 07:13:46
问题 When my app is closed (i.e swiped off by the user from the App Switching menu), it crashes in onMessageReceived() . Here's onMessageReceived() : @Override public void onMessageReceived(String from, Bundle data) { String message = data.getString("message"); from = data.getString("sender"); File notificationsFile = Constants.getNotificationsFlagFile(); ... } It crashes on that last line, giving a null pointer exception : 08-13 21:15:25.535 23201-23216/com.example.myapp E/AndroidRuntime﹕ FATAL

RecyclerView with 100 items loading too slow

好久不见. 提交于 2020-01-07 05:14:07
问题 I have used RecyclerView several times before, but it is the first time that it is working too slow. In this case, the items are represented by a simple LinearLayout with 3 views inside it: <?xml version="1.0" encoding="utf-8"?> <LinearLayout android:id="@+id/linearLayout" android:orientation="horizontal" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content"> <TextView android:id="@+id/tvTicketNumber" android:layout

Android's AsyncTask: multiple params, returning values, waiting

吃可爱长大的小学妹 提交于 2020-01-07 04:23:06
问题 I have been looking at how to implement Android's AsyncTask class for some time now. Basically, I want it to do the classic scenario: simply animate an indefinite loading wheel while I make a network call. However, in practice I'm having some issues getting this to work the way I want. I have code that looks like this currently : (before my desired AsyncTask implementation) String result = timeConsumingNetworkCall(String someData, ArrayList stuff1); doStuff(result); String result =

Activity has leaked window?

人走茶凉 提交于 2020-01-07 03:15:08
问题 I am having one java class in that class as soon some one purchases our application then it will start downloading and progress dialog has to appear instead it goes to some other page and when i come out of the application and when i restart then it starts downloading. Please Help me out from this mess... Thank you 回答1: Check the condition for dialog, before showing. Like this if(pDialog!=null) { if(!pDialog.isShowing()) { pDialog.show(); } } and also while removing the dialog in

Activity has leaked window?

你。 提交于 2020-01-07 03:14:05
问题 I am having one java class in that class as soon some one purchases our application then it will start downloading and progress dialog has to appear instead it goes to some other page and when i come out of the application and when i restart then it starts downloading. Please Help me out from this mess... Thank you 回答1: Check the condition for dialog, before showing. Like this if(pDialog!=null) { if(!pDialog.isShowing()) { pDialog.show(); } } and also while removing the dialog in

check and pull data from server continuously in Android Application

╄→尐↘猪︶ㄣ 提交于 2020-01-07 02:49:28
问题 I want to load data from server synchronously and show it in a view like ListView or TextView without any pulling request each time. I need the data will be loaded if there is any changes in server. Right now I am using asynctask to pull data from server but to load new data or update I need to do pulling request using a reload button. I tried it using a thread which will run after a certain time. But I know there might have some better method obviously. How can I do the same thing without

NullPointerException for ProgressDialog in AsyncTask [duplicate]

时间秒杀一切 提交于 2020-01-07 02:45:09
问题 This question already has answers here : What is a NullPointerException, and how do I fix it? (12 answers) Closed 3 years ago . I have an AsyncTask class within another class in a separate file from MainActivity GetWarehouseSales.java public class GetWarehouseSales extends Activity { private String TAG = MainActivity.class.getSimpleName(); private ListView lv; private ProgressDialog pDialog; //URL to get JSON details private static String url = "http://192.168.0.1/mycc/retrieve_ws.php";

Multiple Images upload in android asynchronously using phonegap

那年仲夏 提交于 2020-01-07 02:36:10
问题 I have an issue with multiple images upload to php server. The code given below works fine for android 2.x versions, but the same code doesn't work for android 4.x and above. I have googled and found out that the data posting has to be done asynchronously by AsyncTask. But I have no clue about how it has to be done via phonegap(calling of async task). Here I have my code : package com.mymedlinks.hybrid; import java.util.TimeZone; import org.apache.cordova.api.Plugin; import org.apache.cordova