FAQ Database Discussion Community


Use async task to modify element in a contact listview

android,json,android-listview,android-asynctask
i want to check if a phonenumber of my contacts is in a database. So far i created a listview with a custom adapter and can display contact name, number and image. I added a fourth field that should display if the phonenumber is in the database. i use asynctask...

android exception NetworkOnMainThreadException (Already used asyncTask but still error)

java,android,android-asynctask
I am building a simple android app but I keep getting this exception NetworkOnMainThreadException. I have researched a lot about this, I understand that on android3.0(honeycomb) os and above, it is stricter, and should use asyncTask (on background thread), and I have done everything that I found, but still getting...

Dynamically changing fragment contents in a ViewPager

android,android-fragments,android-asynctask,android-viewpager
I have: A ViewPager with a FragmentPagerAdapter on (or a FragmentStatePagerAdapter, doesn't really solve my problem). A fixed number of fragments. They all share the same layout, but have TextViews that need to be set differently; An AsyncTask that queries my database and retrieves content to be set into the...

cordova plugin TCPSockets NetworkOnMainThreadException

android,ios,cordova,android-asynctask,tcpsocket
I am trying to get the TCPSockets plugin provided by Habel to work with Cordova 5.0. This plugin can be found here. I can install the plugin but when I use it I get the exception "android.on.NetworkOnMainThreadException". I have researched this error and there seems to be a variety of...

How to get application's context in other method than onCreate in Android Studio?

android,android-studio,android-asynctask
I have an async task which eventually creates the parameters email,about. The async task is in the onCreate method, and so is this CustomListAdapter. I want to move the CustomListAdapter from onCreate in the asyncTask in onPostExecute.My problem is that this means the context of the application. When I move...

How to return a value from Asynctask to activity

android,android-asynctask
How to return a value from Asynctask (Different class) to activity back from which you called the Asynctask , here i have followed the intsruction given in following link How to get the result of OnPostExecute() to main activity because AsyncTask is a separate class? @HelmiB's I have done everything...

Android appUI updating slow

android,database,android-asynctask,ui-thread
In my app when a button clicked, the database is updated first, then that data is sent to the server. Before sending data that data is encrypted. The update to the db is done in one async task and the encryption and sending data is done through another async task...

Getting data from AsyncTask class to the Activity

android,android-asynctask
I am trying to retrieve data from the AsyncTask class's onPostExecute() and set it as the text for textviews of the same activity (so just to test i am using toast to see if it works). I am using an interface (with method processFinish()) as follows to get data from...

Independent time tracking in android app: service or asynctask?

android,android-asynctask,broadcastreceiver,android-service
I'm trying to do a time tracking app: you push "start" on a task, timer launches somewhere, counts its time, after some time limit a notification is shown - "you are late", but timer goes on. App has many activities, timer should update UI on one of them. An it...

updating variables with nested async tasks

android,android-asynctask
I have an IP scanning routine to find web servers on a LAN, then based on the results of this scan, I need to determine which IP address is the one I am looking for by running a second async task in the onPostExecute of the IP scanning routine. The...

Parse the json objects inside json Array in Android?

android,json,android-asynctask,httpclient
I am trying to parse json values into my Android application and put the result in a lisview. There is my JSON result: [ {"dateticket": "12/02/2015", "description": "kkkkkk", "etat": "suivi", "idticket": 32, "nomfichier": "contrat", "objet": "contrat", "priorite": "first"}, {"dateticket": null, "description": null, "etat": "en cours", "idticket": 98, "nomfichier": "lotfi", "objet":...

AsyncTask takes a long time before entering doInBackground()

android,multithreading,android-asynctask
I have an AsyncTask reading from SharedPreferences. When I start the app the first time after installation, the AsyncTask takes a long time to call doInBackground() method. Here is the code: public class ReadSharedPrefsTask extends AsyncTask{ private static final String TAG = ReadSharedPrefsTask.class.getSimpleName(); Context context; String key; Object result; OnReadFinishedListener...

How can I return an ArrayList from my AsyncTask?

android,arraylist,android-asynctask
I have an AsynkTask method on my MainActivity that it's the following: class chargeCars extends AsyncTask<Void, Integer, ArrayList<Car>> { protected void onPreExecute(){ } protected ArrayList<Car> doInBackground(Void... params) { ArrayList<Car> cars = new ArrayList<Car>(); cars.add(new Car(1,"Car1"); cars.add(new Car(2,"Car2"); cars.add(new Car(3,"Car3"); return cars; } protected void onProgressUpdate(){ } protected void onPostExecute(ArrayList<Car> c){...

FATAL EXCEPTION: AsyncTask #1 An error occured while executing doInBackground

php,android,android-asynctask
Help me please, I want to make an barcode scanner and sent the result in my database, but I have errors this is my code : MainActivity.java package common.TER2015; import java.io.IOException; import java.util.ArrayList; import org.apache.http.NameValuePair; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.HttpClient; import org.apache.http.client.entity.UrlEncodedFormEntity; import org.apache.http.client.methods.HttpPost; import org.apache.http.impl.client.DefaultHttpClient; import...

App crash when no internet connection

java,android,eclipse,android-asynctask
so i was trying to create a simple login app connected to my wampserver by following tutorial on internet and it works fine, but the problem occurs when my device is not connected to internet and i can't figure it out why, but i'm pretty sure the problem is in...

Upload multiple photos to SFTP in Async

android,multithreading,android-asynctask,ftp,sftp
I want to upload multiple photos to SFTP server but with the following code only one photo is uploaded. Please anybody has any idea where I m getting wrong or have a better approach for this private class uploadFileOnFTPServerAsync extends AsyncTask<Void, Void, Void> { ProgressDialog pdDialog; @Override protected void onPreExecute()...

Android studio multithreaded downloader

java,android,multithreading,android-asynctask
I am trying to make a multuthreaded downloader which can download a given file by breaking it into 3 chunks and downloading in parallel. The issue is, when I run the code, it seems that Thread 2 doesnt start unless Thread 1 finishes and Thread 1 doesnt start until Thread...

Serializing execution of multiple fragments using AsyncTask

android,android-activity,android-asynctask,fragment
I'm having an activity with 2 fragments, called A and B. Fragment A has an AsyncTask to parse some data from the internet into an array of custom objects and fill its interface. Fragment B also has to use this array to update its interface. The question is, how can...

When findFragmentByTag is called on a fragment with setRetainInstance set to true, the same instance is not returned

android,android-fragments,android-asynctask
I have a a single activity application with two fragments: A fragment with all the UI; A fragment without a view that has an AsyncTask as its member, and setRetainInstance set to true. The goal is to keep the AsyncTask running even after the activity gets destroyed, and reuse it...

UI Objects & ProgressBar - Not Updating AsyncTask

android,android-asynctask
Hi guys added all the code I could below in regards to my problem. Note that both the Progress bar and the text view are NOT UPDATING via asynctask. The textview can be edited in getview method but not the progressbar as when I try to set to 40 it...

How to pass string arguments to AsyncTask in android

java,android,android-asynctask
This must be really easy but I am stuck now for an hour or so. I am passing String[] to an AsyncTask class as such class test extends AsyncTask<String, Void, Void>{ @Override protected Void doInBackground(String... params) { // Again, use either params local to this function // or args local...

Can't dismiss progressDialog from activity callback

android,android-asynctask
I know there are a million similar questions here, but none of the solutions presented there quite addressed the issue I'm having. I have an AsyncTask that loads data from a database. An indeterminate ProgressDialog is displayed while the data is loading (even though in production code it never takes...

I am using AsyncTask for a splashscreen and database load in multiplaces. Is this a good idea?

android,android-activity,android-asynctask,splash-screen
I have a splash screen and main activity. The idea is to show the splash while doing db loads. I can not use the emulation mode as is does not work the same as a apk install directly on the phone. When the APK installs the splash screen shows for...

Update android UI from do in background task

android,user-interface,android-asynctask
I am using AsyncTask to do a background task. The task is in a while loop. How can I update my UI as on post execute dose not work if the background task is still running. Thanks protected String doInBackground(Void... params) { while(true){ Log.i(LOG_TAG, "Executing Background Task"); try{ String dataFromBT...

AsyncTask Dialog Not Dismissed

java,android,android-asynctask,android-dialog
I'm getting some data with an async task but it's always showing on the screen and never dismisses or hides. Why? public class getJson extends AsyncTask<String,Void,String> { @Override protected void onPreExecute() { super.onPreExecute(); pDialog = new ProgressDialog(kategori.this); pDialog.setMessage("Yükleniyor..."); pDialog.setIndeterminate(true); pDialog.setCancelable(false); // ProgressDialog u iptal edilemez hale getirdik. pDialog.show(); } @Override...

Android Location object returns null when I pass it to asyncTask

java,android,android-asynctask
I am sending android user location lat and longitude to server together with registration ID and other parameters as json object in Asynctask(a nested class of the activity). But the Location object(that had values at the start of the app) instantiated in the activity as such location = LocationServices.FusedLocationApi .getLastLocation(mgoogleapiclient);...

NoSuchMethodException for calling doInBackground

android,menu,android-asynctask,nosuchmethoderror
I am new to the Android.On selecting an action in menu item I want to call a method which is in Myclass extends AsyncTask. The method which I want to call is doInBackground. Myclass is a class present in MainActivityFragment.java. My xml for the menu is as follows : <?xml...

Asynctask cant display the server response

android,sockets,android-studio,android-asynctask,tcpclient
I created a socket program on android studio and I want to display the response of the server. The problem is when I'm using textResponse.setText(serverm); it didn't work. this is my code on asynctask private class Connect extends AsyncTask<Void, Void, Void> { final String address = editTextAddress.getText().toString(); String textResponse =...

Why I get java.util.ConcurrentModificationException error?

java,android,arraylist,android-asynctask
I'm having troubles with this code: protected void onPostExecute(ArrayList<Example> examples){ for(Example i : examples) { customAdapter.add(i); } listExamples.setAdapter(customAdapter); } where listExamples it's a ListView that I have in my mainActivity layout. The error that it gives to me it's the java.util.ConcurrentModificationException error. I know that it happens when you modify,...

start AsyncTask from one activity, get result in another

java,android,android-asynctask
I'm new to Android programming, and I'd like to create a central database service class which will take care of user data exchange with an external database. For this, I created a service which is started after successful login. I created another class that extends AsyncTask to do the data...

Need design pattern suggestion: AsyncTask included

android,android-asynctask,android-intentservice
This is my current situation. Class Foo{ public static boolean isAsyncTask1Done; public static boolean isAsyncTask2Done; AsyncTask1(); //in onPostExecute make isAsyncTask1Done= true AsyncTask2(); //in onPostExecute make isAsyncTask2Done= true //execute the following method after the above 2 complete. if (isAsyncTask1Done == true && isAsyncTask2Done == true) doPostProcessing(); } Now this class is...

update qyery for updating a Base64 Image string in android

php,android,android-asynctask,base64,mysql-real-escape-string
i have a php page which is having a update query to update image $email=$_POST['email']; $name = $_POST['name']; $phone= $_POST['mobile']; $buffer = mysql_real_escape_string($_POST['image']); $user_image = base64_decode($buffer); require_once __DIR__ . '/db_connect.php'; $db = new DB_CONNECT(); $q="UPDATE register SET name ='$name', user_image ='$userimage', phone_number = '$phone' WHERE register.email ='$email'"; if ($result) {...

Android volley library, where to use and where not to

android,android-asynctask,android-volley
As our typical old asynctask network connection is getting replaced by volley. It's fast as I have used so I know. I downloaded images and showed. When I again restarted the app it didn't take time to download. So is it caching images for sometime ? And as it is...

calling AsyncTask in main thread inside a for loop

java,android,multithreading,android-asynctask
I have someclass which do large network operations and it do take some time to complete,and hence i put it in AsyncTask .I have to do this process 'n' times so in the main thread using a for loop i called this asynctask n times.will it throw any error since...

Display loadingwheel during method

android,android-asynctask,libgdx
I share an image to different social medias, but this process takes a few seconds and can make the user think nothing is happening. So I want to display a loading wheel sort of. I got the animation finished but I can´t work out how to implement it so that...

Pass parameter to a URL AsyncTask android

android,parameters,android-asynctask
I'm developing an app and now I have to pass a parameter to a RESTful Service's URL. I'm using AsyncTask, and I need to pass a text from a list view as a parameter to the URL, for example: the URL is http://ip:7001/product?product_name=PARAM I need to get the text from...

How do i return a result from a async task [duplicate]

android,android-asynctask
This question already has an answer here: How to get the result of OnPostExecute() to main activity because AsyncTask is a separate class? 9 answers I have been using async tasks to hit a web server and updating controls using the result. This has drawbacks, namely it makes the...

Returning value which is obtained in onPostExecute method of AsyncTask

android,android-asynctask,hashmap
So I'm calling checkbetoutcome() from another activity. My goal is to carry out the AsyncTask and return the finaloutcomes variable which is populated in the onPostExecute() method. How do I achieve this as so that I don't end up with an empty finaloutcomes variable since the AsyncTask is running in...

Unpredictable behavior when accessing View from another thread

android,multithreading,android-asynctask
I was trying to build an app which have some thread usage. While working I found unpredictable behavior while I was trying to access a TextView from thread. I know android forbid us from accessing views directly from another thread.I also know how to access main thread's views from another...

How to execute and receive results from AsyncTasks outside of the main thread?

android,multithreading,android-asynctask
I have a bunch of AsyncTasks and their callbacks (listener interfaces) that I dont want to have anything to do with the UI thread. Reading the answer here: Android : can AsyncTask return in another thread than UI thread? I am left with the impressin that I can only start...

Fragment AsyncTask not executing after back button pressed

android,android-fragments,android-asynctask
My program is structured as follows from a navigation standpoint: Fragment A -> Fragment B -> Fragment C (back button pressed) -> Fragment A I have an async task that normally fires in onActivityCreated in Fragment A: fetch = new FetchVenues(this, user); fetch.execute(); After navigating to other fragments, I handle...

An error occured whil executing doInBackground

android,multithreading,android-asynctask
I recently wrapped a main thread method in an AsyncTask. It seems to think that something in my code is still trying to access the UI thread. But I'm not sure what it is - here is my AsyncTask: private class showNextRandomQuestion extends AsyncTask<Void, Void, String> { @Override protected String...

prevent asynctask to run after intent and starting the activity

android,android-intent,android-asynctask
I have tried to prevent an asynctask to run after changing the activity through intent but even after calling finnish() the activity is still creating. I am trying to see if a user got filled the username/password or not in my application, if they are not filled it should be...

In Android AsyncTask not fetching the doInBackground error message

android,android-asynctask
My requirement:- In My Android project I am using javamail to connect to gmail .. So,I want When I click the button,A progress dialog will start and in the background it will try to connect to gmail..If it the username and password is correct,means it connects to gmail..then will go...

How Can I Fetch Name and Email using Facebook SDK 4?

android,facebook-graph-api,android-asynctask,android-logcat,android-facebook
I am using Facebook SDK 4 ,I had Do this before sdk 2... but for me some syntax has changed so I had faced some problem... I'm not able to fetch username,email This is my XML File <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:facebook="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <com.facebook.login.widget.LoginButton android:id="@+id/LoginFbButton"...

AsyncTask crashes after first line?

java,android,android-asynctask
I am trying to build an application that calls a webservice through an AsyncTask, however, the app always crashes after the first line of the AsyncTask. Below is my code for the AsyncTask: protected class AsyncGetItemByKey extends AsyncTask<String, JSONObject, ItemTable> { String userName=null; @Override protected ItemTable doInBackground(String... params) { itemTable...

AsyncTask is not running when called with execute

android,android-asynctask,android-service
I am trying to run an AsynTask that updates a local data every minute. I have placed logging statements in all paths of the AsyncTask, yet none of them are ever called. Am I not creating/running the async task correctly? Here is the receiver calling the function (I know that...

should I replace AsyncTask implementation with AsyncTaskLoader

android,android-asynctask
I need to request data from webservice. I've implemented the following AsyncTask to do that: class LoadTagsTask extends AsyncTask<Void, Void, String> { private String url = "http://webservice.com/rest/tagsManager/search"; ProgressBar loader; @Override protected void onPreExecute() { loader = (ProgressBar) TextsListActivity.this.findViewById(R.id.textLoadingProgressBar); loader.setVisibility(TextView.VISIBLE); } @Override protected String doInBackground(Void... params) { HttpURLConnection c = null;...

Sweet alert in an AsyncTask Android

android,android-asynctask,sweetalert
I'm trying to put a sweet alert of https://github.com/pedant/sweet-alert-dialog library and it works perfect, but not in an AsyncTask. my onPostExcute: protected void onPostExecute(String result) { super.onPostExecute(result); if(!Pattern.compile("0").matcher(msj).find()) { Toast.makeText(ctx, "¡Ya tienes una reserva para este viaje!", Toast.LENGTH_SHORT).show(); }else if(Pattern.compile("200").matcher(msj).find()) { SweetAlertDialog swt = new SweetAlertDialog(ctx, SweetAlertDialog.WARNING_TYPE) .setTitleText("Todas las plazas...

Asynctask not working

android,android-asynctask
//packagename imports ,variable @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //declaring views lv_IFSC_.addFooterView(Btn_Load_More); Btn_Load_More.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { // Starting a new async task new Asynctask_Record_List().execute(); } }); final Handler handler = new Handler(); handler.post(new Runnable() { public void run() { try { new...

Pass Variable from Activity to AsynTask

java,android,android-asynctask,location
I have a App with a Navigation Drawer and some fragments. In my MainActivity i get the actual lat & long Location of the device. On my first Fragment in the drawer i load in a AsyncTask some stuff out of my Database on my Webserver For this request i...

Have a fragment re-load on post execute

android,android-fragments,android-asynctask
I have a fragment which calls an async task. When the async task is done I want the fragment to completely re-load. Basically, my fragment loads a random review. The user then rates the review with a star bar at the bottom. When they click the star bar a async...

Pass Integer[] to AsyncTask - Android

android,android-asynctask,integer
I am having trouble passing an ArrayList to a class that extends AsyncTask. The AsyncTask class, DownLoaderTask, is created in the DownloaderTaskFragment class. The code for the DownloaderTaskFragment and DownLoaderTask are below. The MainActivity of this application passes the ArrayList to the fragment by setting Bundle arguments. In the code...

AsyncTask data communication with nested Classes

java,android,android-activity,android-asynctask,http-post
I have a specific scenario and I need your help. I'm trying to build an App in Android that involves network communication. I am using AsyncTask for the http POST requests. I have another class called Proxy (not a good one.. will be changed) which holds different kinds of functionalities...

Andriod setadapter Null pointer

android,android-asynctask
I have following fragment public class Tab2 extends Fragment { // Progress Dialog private ProgressDialog pDialog; // Creating JSON Parser object JSONParser jParser = new JSONParser(); ArrayList<HashMap<String, String>> contactsList; // url to get all contacts list //private static String url_all_contacts = "http://192.168.100.28/andriod_product_demo/get_all_contacts.php"; // JSON Node names private static final String...

One AsyncTask for multiple Fragments

android,android-fragments,android-asynctask
I'm Writing an application in Which i have different fragment. In all Fragment i have to use Async Task for fetching data from web server for that i have written a common Async class and implement an interface for getting result but there is casting error i don't know why?...

FATAL EXCEPTION: AsyncTask caused by ConcurrentModificationException

java,android,android-asynctask,concurrentmodification
I am new to Android and developing in general so any help is appreciated. Most of the questions (and answers) about a "FATAL EXCEPTION in an AsyncTask" were NullpointerExceptions so I think I am allowed to ask. I use this Midi-driver https://github.com/kshoji/USB-MIDI-Driver to get notes from an external keyboard. I...

Update UI from AsyncTask and handle properly screen rotate

android,multithreading,android-asynctask,handler
This code doesn't works when rotate screen. I try to use Handler but messages are dispached to previous Activity(before rotate) and to new Activity. ¿How can a thread send messages to new Activity? Please doesn't suggest avoid to rotate screen. public class SampleActivity extends Activity { TextView text; Handler handler;...

Multiple connections to SQLite with simultaneous async Tasks

android,sqlite,android-asynctask,parallel-processing
In my scenario it has Sync_Class that syncs, with AsyncTasks in background , from my app to my server. Every time that my app does one action that need to change data from my SQLite, as first step my app updates my local database as second step throws a AsyncTask...

Android AsyncTask and Login

android,jdbc,login,android-asynctask
I was writing an Android Login Page and i used a Class that extended AsyncTask. The problem is that it seems that i can't "control" the flow of the Async Task. If i insert correct username and password, if i click one time when it connects to the database it...

Android app crashes when using AsyncTask for fetching an url with jsoup

android,android-asynctask,jsoup,assets
So the app shows up the dialog while loading but then crashes. Te reason I decided t use these technologies is because I have to load an html, which changes dynamically and there are heavy CSS files which I would like to cache, so I think including them as assets...

AsyncTasks takes several seconds to start

android,android-asynctask
In my app, i have an Activity A that hosts Fragments. From an (child) Activity B, I display a specific Fragment in Activity A, then finish B. let's call this Fragment F1. In F1, I create an AsyncTask to read data from my database. The AsyncTask is created at the...

Android: NullPointerException when trying to load videoview through AsyncTask [duplicate]

java,android,android-asynctask,nullpointerexception,videoview
This question already has an answer here: What is a Null Pointer Exception, and how do I fix it? 12 answers I created a fragment for my VideoView in my android project. I tried to load the VideoView with the video in my backgroundtask. My code: public class VideoPlayer...

Executing doInBackground() error and Activity has leaked window when I attempt to do JsonParsing

php,android,mysql,json,android-asynctask
I'm a beginner in Android. Currently, I successfully retrieve all data through Json Parser and PHP and display data on my Android app. The mysql query in my php file is: mysql_query("SELECT * FROM jobs) Now, I try to revise it as: mysql_query("SELECT * FROM jobs WHERE PostName = '{$_GET["PostName"]}'...

What is the best way to use the insert, delete and update from an Content Provider?

android,android-asynctask,android-contentprovider,crud,loader
I am spinning my head around this theme for quite some time. I don't have much experience with Android and I'm trying to code everything using the best approach I can. I successfuly created a Content Provider to wrap my SQLite and some Loaders to query the Data. It works...

unable to start activity from onPostexecute() using interface

android,interface,android-asynctask
I need to start another activity from the onPosExecute method of the AsyncTask. The AsyncTask is a seperate class and not in any activity class. I have used an interface to do so. The codes are: This is the onPostExecute() method @Override protected void onPostExecute(String json) { Log.v("JSON", json); Log.v("updateUI",""+updateUI);...

Thread Runnable vs AsyncTask Life Cycle

java,android,multithreading,android-asynctask,runnable
I would like to better understand what happens to a Thread or a AsyncTask when activity is destroyed. So in this scenario, a Thread or AsyncTask would be started from activity, and user hits home button and onDestroy gets called triggering GC before either Thread of AsyncTask had a chance...

Exception trying create a RSS Reader?

android,android-fragments,android-asynctask,rss
I'm trying create a rss reader to my app, the problem is when I try display my Fragment doesn't works and throws an exception and doesn't works. I'm trying follow this sample: https://androidresearch.wordpress.com/2012/01/21/creating-a-simple-rss-application-in-android/ How could I do this ? RSS Reader Fragment public class RSSReaderFrag extends Fragment implements AdapterView.OnItemClickListener{ private...

Cancelling asynctask for list view adapter before its finished

android,android-listview,android-asynctask,adapter
I need to cancel my asynctask populating a list view adapter before it has finished by pressing back button. By this code @Override public View getView(final int position, View convertView, ViewGroup parent) { if(convertView==null){ LayoutInflater inflater=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);convertView=inflater.inflate(R.layout.seatadapter, null); TextView text3=(TextView)convertView.findViewById(R.id.text3); ProgressBar progressBar1=(ProgressBar)convertView.findViewById(R.id.progressBar1);...

Getting: “java.lang.NullPointerException” but I know object is instantiated in AsyncTask

java,android,android-asynctask,nullpointerexception
I am attempting to pass a string I got in an Asynchronous task class back in to my main activity, but when I pass the string result (which I know isn't null because logging the string right before passing it to the interface outputs what it should), I get a...

AsyncTask kills my app when I execute ProgressDialog.show() method

android,android-fragments,android-asynctask
The title is clearly. When I launch AsyncTask my app crash. Exactly the problem is in the ProgressDialog's show method. I launch my AsncTask from a Fragment (onCreate method). @Override public void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); context = getActivity().getBaseContext(); LoadLastNewAsync llna = new LoadLastNewAsync(context, lang);...

Why am i getting an empty value from my doInBackground when using AsyncTask in an IntentService class?

android,android-asynctask,intentservice
I am trying to insert some points into a table in a database. For this i am using an IntentService, but i am getting an empty value from onPostExecute(i checked using debug). I am in doubt whether this is a good way to achieve this?- The problem is i can...

Error on ruOnUiThread inside asychtask

android,json,android-asynctask,android-runonuithread
I am trying to parse some data from server and compare the data with the data in the database... Everything seems working fine... except I am getting only same value even the comparing data change... I'll explain it with the code... In the below code, there is textviews tv3 and...

Assign value returned by AsyncTask

java,android,multithreading,android-asynctask
public class Login extends ActionBarActivity{ . . . // I have this method to run If the login button is pressed. public void login(View v){ // I am performing all verification and validation // Just not showing it here // To store the keys String api_key_from_database; String api_key_from_network; //Gets the...

saving data safely before Activity is destroyed

android,android-asynctask,activity-lifecycle
i need to save some crucial importance data when user closes my app. i prefere to do this in Activity's onPause(), as it is the latest method guaranteed to be called before the application is destroyed no matter what is the reason of its destruction. however, i save the data...

Following this tutorial but I'm stuck on the asyncTask

java,android,android-asynctask
I am a beginner learning to develop android application, and I am currently following this simple tutorial at http://www.androidhive.info/2012/05/how-to-connect-android-with-php-mysql/, but on one of the page I am having problem with NetworkOnMainThreadException, which after I researched, android 3.0 and above will throw the exception when performing http request on UI thread,...

AsyncTask in baseadapter [duplicate]

android,android-asynctask
This question already has an answer here: android.os.NetworkOnMainThreadException 30 answers i am using listview with baseadapter . every row listview have 2 button. i set event on thats buttons. this is my problem before link and this is my code now public class customadapter extends BaseAdapter{ ArrayList<HashMap<String, String>> oslist;...

onPostExecute() does not send the intent to the onNewIntent() in the backgroud

android,android-intent,android-asynctask
I am facing problem with onPostExecute() in the background so I am sending data like long, lat, mac to the server every 30 seconds and a response is coming back with the result as: { "status":230, "routes":[9, 11], "distance":293.3018920430205 } which are being processed well when the App runs in...

AsyncTask is publishing progress after cancelled

java,android,android-asynctask
My situation is a RecyclerView of invoices that can be downloaded. They have an action that starts the download and shows the progress in a circular progress view around the download button itself. I use an AsyncTask to download the particular invoice in PDF format, with a custom listener so...

AsyncTask send bool value to C# WebService

android,web-services,android-asynctask
I have a problem about sending bool value to webservice. Here is background code protected Void doInBackground(Void... params) { try { method = new WebServiceGlobalMethod(sendedOrReceived, "Object"); method.request.addProperty("TC", UserInfo.TRNo); method.request.addProperty("IsStudent", UserInfo.IsStudent); method.Method(); } catch (Exception e) { e.printStackTrace(); } return null; } I'm sending 2 value; TC is long number, IsStudent...

Android crash in AsyncTask

java,android,android-activity,android-asynctask,progressdialog
When I run my projent and it's run AsyncTask from the activity that shows all content of the item the APP crash showing the follow error message: 06-17 20:56:52.856 418-428/? E/art﹕ Failed sending reply to debugger: Broken pipe 06-17 20:57:07.391 418-767/com.example.user.project_test E/AndroidRuntime﹕ FATAL EXCEPTION: AsyncTask #3 Process: com.example.user.project_test, PID: 418...

An error occured while executing doInBackground() when I submit user input to the server

java,android,android-asynctask
I'm a beginner. I'm currently creating an app having connection between users and my server. For example, the user inputs some info and click the button then all the info will save in my server DB table. Howerver, after inputting the info and click the button, the app crushes. the...

android AsyncTask does not dismiss Progressbar

android,android-asynctask
In my app i need to make call for AsyncTask in for loop like this protected void runSearch(String query) { for (int i = 0; i < MAX_RESULT_COUNT; i += PAGE_SIZE) { try { String s = SEARCH_ENDPOINT + "&q=" + URLEncoder.encode(query, "UTF-8") + "&start=" + i; // Toast.makeText(this, "qUERY>>...

Is chaining AsyncTasks considered bad practice? [duplicate]

java,android,multithreading,android-asynctask
This question already has an answer here: Android AsyncTask - Order of execution 6 answers I'm writing an app that does the following: Parses a webpage and extracts image URLs from it Decodes them to Bitmap and shows them in an ImageView I don't want these to run on...

Android - ListView with AsyncTask implementation using JSOUP

java,android,html,android-asynctask,jsoup
I need some advice, because this thing took me enough time to be angry on myself for lack of knowledge... I try to make a ListView filled by JSOUP-extracted data. And the JSOUP part is in AsyncTask. Here is my code: public class ListaActivity extends ActionBarActivity { private List<String> mList...

Android: Display current track Info in mediaplayer using webpage

android,android-asynctask,inputstream,android-mediaplayer,runnable
I am a learner and developing an Android App to play live stream. It is working properly except 1 issue. I want to show title of currently playing Track which is available on a webpge. For this purpose I have used a textView and tried to use Asynchronous Task and...

How to show alert dialog in a running thread using AsynctTask? [duplicate]

java,android,multithreading,android-asynctask,runnable
This question already has an answer here: android.os.NetworkOnMainThreadException at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1117) [closed] 3 answers How can I show an AlertDialog using runnable Thread in doInBackground method, I'm using AsyncTask and I need to use a running thread to show a message that I receive from my API, but the dialog...

Using AsyncTask and restarting method

java,android,android-asynctask
It's my first project so excuse me for rough code, especially for this if() thing;) I will try to fix it later. 1 Problem - When app starts it's doesn't show UI what I did in Activity Main layout.My UI shows up when result is sent to display. I think...

Asynctask closing before loading URL

android,android-asynctask
I am trying to use Asynctask to first check if website is accessible and then open it. The problem is the progress dialog closes before the website is fully loaded. public class MainActivity extends Activity { private final static String TAG = "MusicFXActivityBrowser"; /** Called when the activity is first...

Android: Making application wait before executing task (AsyncTask usage)

java,android,multithreading,sqlite,android-asynctask
Hello I will define my problem more clearly here. I am working on my first Android App that reads simply an NFC Tag and compares it to an SQLite database stored on the device. In short, if this is successful (Tag is ok, code exists in the database) the screen...

Android Servlet AsyncTask #1 Fatal Exception

java,android,servlets,android-asynctask
I was having some problem when trying to retrieve data via Servlet into Android using JSON. So basically here is my controller class: public String GetPwd(SoccerUserModel userModel) throws JSONException { String page, pwd = null; JSONArray jsonArray; try { String userName = userModel.getUserName(); String securityQuestion = userModel.getSecurityQuestion(); String securityAnswer =...

Entity returns error in MultiPartEntityBuilder

android,android-asynctask,multipartentity
I've tried following links but none of them helped to solve the issue. HttpPost returning error when using MultipartEntityBuilder in Android http://stackoverflow.com/a/22803149/1226882 Here's the code HttpClient httpClient = new DefaultHttpClient(); HttpPost httpPost = new HttpPost(Utility.AddProductWS); MultipartEntityBuilder multipartBuilder = MultipartEntityBuilder.create(); /* example for setting a HttpMultipartMode */ multipartBuilder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE); for (int i...

java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive a notification - List with Universal Image Loader

android,listview,android-asynctask,android-adapter,universal-image-loader
I am trying to update a fragment with list view once the Async call is complete but I am getting the following error : java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive a notification. I am updating the adapter onPostExecute and have also checked the...

ProgressDialog not showing up in onPreExecute()

java,android,android-asynctask,progressdialog
I saw that .get() is the problem, but I try without him and nothing. If possible help me. The ProgressDialog execute after doInBackground() and after run onPostExecute "dismiss" and then ProgressDialog not show. public List<Usuario> getListaUsuario(Activity activity) { String[] aux = new String[3]; aux[0] = URL_WS_USUARIO; String[] resposta = null;...

Can I update the UI of an activity which is in background?

android,android-activity,android-asynctask,android-service
The question is more conceptual than coding-related. I have an app with Activity A and B. I call an AsyncTask from Activity A, while the call is being made, I don't want to block the user showing the progressdialog, so my user can freely move around the application without getting...

Get Response, Url and Url code in Textview

android,android-asynctask,textview,android-textview
I am trying to make a post request to a url and get the URL, Response Code and Response displayed in a TextView. I am able to get the URL and Response Code in the Logs but Unable to get the response. Please check the code and tell how to...

Executing a method in loop via AsyncTask - Android?

java,android,loops,android-asynctask
I am kinda noob in programming, but I am here to ask you for an advice. I am making an app, which serves you an system informations like CPU load, RAM, etc.. I've got all I need, and it works! But there is a problem when I push button which...

Frequent usage of asynctask

android,android-asynctask
I have created an AsyncTsak class in my project which downloads some information from web server. I am sure that it works well because when it is called by onCreate() , I can see the result . But unfortunately when I call it again via a button it doesn't work....

Display Toast from AsyncTask until event occurs

android,android-asynctask,toast
I would like to display "Connecting ..." using Toast until the device is connected to a new network (more specifically when an IP address is obtained, see the while loop in doInBackground below). I am using AsyncTask for connecting to the network, but if I put Toast.makeText(...).show() inside onProgressUpdate() the...

How to simple deal with progress dialog with AsyncTask and fragment?

android,android-fragments,android-asynctask
I want to use a ProgressDialog within a Fragment for an AsyncTask. With Activity the following code works perfectly, but with Fragment no. public class ResultTask extends AsyncTask<String, Void, Report> { private ProgressDialog pDialog; private Context context; public ResultTask(Context context) { super(); this.context = context; } @Override protected void onPreExecute()...