Note that there are some explanatory texts on larger screens.

plurals
  1. POQueuing images path when there's no internet connection
    primarykey
    data
    text
    <p>I'm havin difficulties of keeping track of my queue. I'm trying to store image-paths into a queue so i can use the queue to start uploading my images once there's internet (at a later moment). The upload image is an asynctask and in the postExecute i'm trying to send a mail with the uploaded picture attached to it in another asynctask.</p> <p>This is my UploadImage AsyncTask. I think i'm doing way too difficult and that it can be done much easier than it is right now.</p> <pre><code>private class UploadImageTask extends AsyncTask&lt;Void, Void, Integer&gt; { ProgressDialog dialog; /** * Private integer which counts how many times we've tried to upload the * Image. */ private int _counter = 0; private List&lt;String&gt; imageUploadList = new ArrayList&lt;String&gt;(); @Override protected void onPreExecute() { super.onPreExecute(); if(AppStatus.haveNetworkConnection(_context)){ if(isPhotoTaken()){ dialog = new ProgressDialog(Step4.this); dialog.setCancelable(false); dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); dialog.setMessage(getString(R.string.uploadingMessage)); dialog.setTitle(getString(R.string.uploadingTitle)); dialog.show(); } } } protected Integer doInBackground(Void... params) { init(); postData(); return null; } public void init(){ _counter = 0; _beenHere = true; for(String path : imageUploadList){ Debug.out("Path: "+path); } } public void postData() { if (isPhotoTaken()) { if(AppStatus.haveNetworkConnection(_context)){ if(_beenHere){ ImageUploader.uploadFile(getPhotoPath(), "http://obo.nl/android-upload-image.php", Step4.this); } else { for(String path : imageUploadList){ Debug.out(path); ImageUploader.uploadFile(path, "http://obo.nl/android-upload-image.php", Step4.this); } } } else { if (_counter == 0) { _counter++; _activity.runOnUiThread(new Runnable() { public void run() { Toast.makeText(_context, getString(R.string.noInternetImageNotUploaded), Toast.LENGTH_LONG).show(); } }); imageUploadList.add(getPhotoPath()); } try { if(_beenHere){ _beenHere = false; goToNextIntent(); } Thread.sleep(10000); } catch (InterruptedException e) { e.printStackTrace(); } postData(); } } } private void goToNextIntent(){ Intent intent = new Intent(Step4.this, Step5.class); intent.putExtra(EXTRA_MESSAGE, (Serializable) _user); intent.putExtra(EXTRA_MESSAGE2, _isRepairable); intent.putExtra(EXTRA_MESSAGE3, _injury); intent.putExtra(EXTRA_MESSAGE4, _category); intent.putExtra(EXTRA_MESSAGE5, _inch); intent.putExtra(EXTRA_MESSAGE6, _size); startActivity(intent); } protected void onPostExecute(Integer result) { if(isPhotoTaken()){ if(dialog != null){ dialog.dismiss(); } } mailing(_isRepairable); new MyAsyncTask().execute(_mail); } } </code></pre> <p>The line:</p> <pre><code>if(AppStatus.haveNetworkConnection(_context)) </code></pre> <p>returns a boolean true if the user has a working internet connection. false otherwise.</p> <p>What I want is to queue all the image paths (and mails sent afterwards) in the desired ArrayList so i can send them all at a later moment when the user has a working internet Connection. Please help me out!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload