• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

how to cancel AsyncTask  RSS feed

 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do i cancel a  download when its running. I want to cancel the whole MyAsyncTask, but I can't figure out how to do it. can someone  give a line to cancel this task


 
Bartender
Posts: 9496
184
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The documentation of AsyncTask tells you exactly how to do that.
 
Tony fig
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The document says to use MyAsyncTask.cancel(true); in your call but when i put the line of code to call MyAsyncTask, i get a red underline under the cancel. so im not doing something right. can you tell me why that is?
 
Saloon Keeper
Posts: 2156
278
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you trying to call cancel(true) on the class or the instance?
 
Rancher
Posts: 3350
33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

i get a red underline  


Can you have the compiler give you a full error message so you know what the problem is?
 
Tony fig
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes i am..do you know what im doing doing wrong?
 
Tony fig
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here are the errs when i try to compile it.


MERGED from [com.android.support:support-compat:26.1.0] /home/tony/.gradle/caches/transforms-1/files-1.1/support-compat-26.1.0.aar/aa4690cd8797eebed39d53410164325d/AndroidManifest.xml:26:9-28:38
MERGED from [com.android.support:support-compat:26.1.0] /home/tony/.gradle/caches/transforms-1/files-1.1/support-compat-26.1.0.aar/aa4690cd8797eebed39d53410164325d/AndroidManifest.xml:26:9-28:38
android:value
ADDED from [com.android.support:appcompat-v7:26.1.0] /home/tony/.gradle/caches/transforms-1/files-1.1/appcompat-v7-26.1.0.aar/f10c61b4db4e1da2a31cfd62d4196836/AndroidManifest.xml:28:13-35
android:name
ADDED from [com.android.support:appcompat-v7:26.1.0] /home/tony/.gradle/caches/transforms-1/files-1.1/appcompat-v7-26.1.0.aar/f10c61b4db4e1da2a31cfd62d4196836/AndroidManifest.xml:27:13-51
meta-data#android.arch.lifecycle.VERSION
ADDED from [android.arch.lifecycle:runtime:1.0.0] /home/tony/.gradle/caches/transforms-1/files-1.1/runtime-1.0.0.aar/5a428de0f5d86550cde9787ce402b65a/AndroidManifest.xml:25:9-27:47
android:value
ADDED from [android.arch.lifecycle:runtime:1.0.0] /home/tony/.gradle/caches/transforms-1/files-1.1/runtime-1.0.0.aar/5a428de0f5d86550cde9787ce402b65a/AndroidManifest.xml:27:13-44
android:name
ADDED from [android.arch.lifecycle:runtime:1.0.0

] /home/tony/.gradle/caches/transforms-1/files-1.1/runtime-1.0.0.aar/5a428de0f5d86550cde9787ce402b65a
/AndroidManifest.xml:26:13-58

4-12 23:47:49.011 384-384/? E/WVMExtractor: Failed to open libwvm.so
04-12 23:47:49.027 782-784/android.process.media D/dalvikvm: GC_CONCURRENT freed 369K, 5% free 11026K/11527K, paused 0ms+0ms, total 4ms
04-12 23:47:49.039 782-926/android.process.media V/MediaScanner: pruneDeadThumbnailFiles... android.database.sqlite.SQLiteCursor@536ea290
04-12 23:47:49.043 782-926/android.process.media V/MediaScanner: /pruneDeadThumbnailFiles... android.database.sqlite.SQLiteCursor@536ea290
04-12 23:47:49.335 354-428/system_process D/Tethering: MasterInitialState.processMessage what=3
04-12 23:47:49.339 354-428/system_process D/Tethering: MasterInitialState.processMessage what=3
04-12 23:47:49.339 354-508/system_process D/SystemClock: Setting time of day to sec=1523576873
04-12 23:47:53.679 354-510/system_process D/GpsLocationProvider: NTP server returned: 1523576870687 (Thu Apr 12 23:47:50 GMT 2018) reference: 10391 certainty: 10 system time offset: -2988
04-12 23:47:53.703 695-812/com.android.deskclock V/AlarmClock: AlarmInitReceiver finished
04-12 23:47:53.703 354-428/system_process D/Tethering: MasterInitialState.processMessage what=3
04-12 23:47:53.703 354-428/system_process D/Tethering: MasterInitialState.processMessage what=3
04-12 23:47:53.743 782-784/android.process.media D/dalvikvm: GC_CONCURRENT freed 442K, 5% free 11030K/11591K, paused 13ms+1ms, total 32ms
04-12 23:47:56.075 444-444/com.android.systemui D/OpenGLRenderer: TextureCache::get: create texture(0xb8a6b148): name, size, mSize = 24, 5616, 345228
04-12 23:48:00.043 524-524/com.android.launcher D/OpenGLRenderer: TextureCache::callback: name, removed size, mSize = 4, 57344, 2313664
04-12 23:48:00.043 524-524/com.android.launcher D/OpenGLRenderer: TextureCache::callback: name, removed size, mSize = 6, 36864, 2276800
04-12 23:48:00.043 524-524/com.android.launcher D/OpenGLRenderer: TextureCache::callback: name, removed size, mSize = 8, 36864, 2239936
04-12 23:48:00.043 524-524/com.android.launcher D/OpenGLRenderer: TextureCache::callback: name, removed size, mSize = 10, 36864, 2203072
04-12 23:48:00.043 524-524/com.android.launcher D/OpenGLRenderer: TextureCache::callback: name, removed size, mSize = 11, 36864, 2166208
04-12 23:48:00.043 524-524/com.android.launcher D/OpenGLRenderer: TextureCache::callback: name, removed size, mSize = 12, 36864, 2129344
04-12 23:49:18.730 354-507/system_process W/ThrottleService: unable to find stats for iface rmnet0
04-12 23:50:11.246 354-356/system_process D/dalvikvm: GC_CONCURRENT freed 589K, 6% free 13381K/14215K, paused 1ms+1ms, total 19ms
04-12 23:51:48.445 66-66/? D/Genyd: Received Set Clipboard
04-12 23:51:48.445 66-66/? D/Genymotion: Received Set Clipboard
04-12 23:51:48.469 354-439/system_process I/ClipboardService: Got clipboard for user=0
04-12 23:51:48.469 354-439/system_process I/ClipboardService: Got clipboard for user=0
04-12 23:51:48.469 354-367/system_process I/ClipboardService: Got clipboard for user=0
04-12 23:51:48.469 354-367/system_process I/ClipboardService: Got clipboard for user=0
04-12 23:51:48.469 354-367/system_process I/ClipboardService: Got clipboard for user=0
 
Ron McLeod
Saloon Keeper
Posts: 2156
278
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Tony fig wrote:yes i am..do you know what im doing doing wrong?


Are you trying to call cancel(true) on the class or the instance?  Which one?
 
Tony fig
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
its a simple question that im asking all i want to know is how can I cancel the download?
 
Norm Radder
Rancher
Posts: 3350
33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where is the compiler's error message in all those lines you posted?  They look more like  logcat contents from when the program is executed.
Can you just compile the class and not try to run it?

You need to fix the "red line" so the cancel method will work.


 
Rancher
Posts: 506
15
Java Notepad
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Tony fig wrote:its a simple question that im asking all i want to know is how can I cancel the download?



It depends on your app's functionality. In case you have a cancel task button, the button's listener method can cancel the async task. Also, note that the cancel can also be called from an Activity's callback method (e.g., onStop method).
 
Stephan van Hulst
Bartender
Posts: 9496
184
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Tony fig wrote:its a simple question that im asking all i want to know is how can I cancel the download?


It's also a simple answer. You call the cancel method on your task object and, as the documentation says, you have to periodically check whether the task was cancelled from within your doInBackground method, so that it can stop doing what it's doing.

Ron already hinted that you might be calling the cancel method on the AsyncTask class, rather than on your instance of it. If you don't confirm whether or not that's happening, we can't help you much further.
 
Stephan van Hulst
Bartender
Posts: 9496
184
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I merged your stuff with the following thread. I hope that is okay by you.
 
Tony fig
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have figured out how to put together the AsymcTask to cancel it but the cancel isn't working. can you tell me why its not. here is by code


 
Ron McLeod
Saloon Keeper
Posts: 2156
278
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With your code, you are only checking if it was cancelled after there was data to read.  Why not include checking isCancelled() as part of the logic in the while statement's expression?

Also, it would be useful to write a message to your log that a cancel was actually detected.

 
Norm Radder
Rancher
Posts: 3350
33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try debugging the code by adding some print statements to show where the code is executing and not executing.  For example print before and after the openConnection and again after the getInputStream.
The print out will be in the logcat.
 
Tony fig
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Norm, thanks for awesome example but it's still not canceling out. the download wont stop downloading.
 
Norm Radder
Rancher
Posts: 3350
33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Copy the print out and post it showing where the code is executing so we can see where.
Add System.currentTimeMillis() to the print out so the time of the event is shown.  May be redundant if logcat has a date/time stamp.
Also add isCancelled() to the print out.
Make sure there is a print inside the loop that shows len.
 
Tony fig
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here is the print out for the len
04-13 06:47:40.223 3928-3955/com.example.tony.xtreme_online_stations D/1440:  len
this is what i got when I tried to cancel it
04-13 06:47:40.327 354-371/system_process W/BatteryStatsImpl: Couldn't get kernel wake lock stats
04-13 06:47:40.479 3928-3955/com.example.tony.xtreme_online_stations D/552:  len
 
Tony fig
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this is what i got for the cancel
04-13 06:46:15.336 384-399/? W/genymotion_audio: out_write() limiting sleep time 113560 to 39909
04-13 06:46:15.536 3928-3955/com.example.tony.xtreme_online_stations D/276:  len
 
Tony fig
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
got this one two


04-13 06:45:25.773 384-3947/? W/TimedEventQueue: Event 44 was not found in the queue, already cancelled?
04-13 06:45:25.921 3928-3955/com.example.tony.xtreme_online_stations D/276:  len
 
Tony fig
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here is the print for the System.currentTimeMillis


04-13 07:03:00.723 4077-4100/com.example.tony.xtreme_online_stations D/-1110169356:  System.currentTimeMillis
 
Tony fig
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here is the onCancelled()

04-13 07:18:50.155 4201-4224/com.example.tony.xtreme_online_stations D/false: onCancelled() called
 
Tony fig
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it only prints the onCancelled() when when I start the download. or else it wont detect the cancel.
 
Norm Radder
Rancher
Posts: 3350
33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The print out should show the value of the len variable, not the String "len"
System.out.println("len="+len  + " at time="+  System.currentTimeMillis());

You should copy the full text of print out and paste it here so we can see the first line printed through the last line printed.  What you posted looks like you selected out some of the lines to copy and paste not all of the lines.  The posted lines are not in sequence by time.  The time shown at the start of the lines are not in sequence.

The purpose of the print out is to show where the code executed and what the values of selected variables were when the statement was executed.
For example what was the value of len and the value of isCancelled() inside of the while loop?
 
Tony fig
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[code=java]
04-13 10:24:28.147 5845-5845/? D/dalvikvm: Late-enabling CheckJNI
04-13 10:24:28.279 5845-5845/com.example.tony.xtreme_online_stations I/dalvikvm: Could not find method android.view.Window$Callback.onPointerCaptureChanged, referenced from method android.support.v7.view.WindowCallbackWrapper.onPointerCaptureChanged
04-13 10:24:28.279 5845-5845/com.example.tony.xtreme_online_stations W/dalvikvm: VFY: unable to resolve interface method 16004: Landroid/view/Window$Callback;.onPointerCaptureChanged (Z)V
04-13 10:24:28.279 5845-5845/com.example.tony.xtreme_online_stations D/dalvikvm: VFY: replacing opcode 0x72 at 0x0002
04-13 10:24:28.279 5845-5845/com.example.tony.xtreme_online_stations I/dalvikvm: Could not find method android.view.Window$Callback.onProvideKeyboardShortcuts, referenced from method android.support.v7.view.WindowCallbackWrapper.onProvideKeyboardShortcuts
04-13 10:24:28.279 5845-5845/com.example.tony.xtreme_online_stations W/dalvikvm: VFY: unable to resolve interface method 16006: Landroid/view/Window$Callback;.onProvideKeyboardShortcuts (Ljava/util/List;Landroid/view/Menu;I)V
04-13 10:24:28.279 5845-5845/com.example.tony.xtreme_online_stations D/dalvikvm: VFY: replacing opcode 0x72 at 0x0002
04-13 10:24:28.279 5845-5845/com.example.tony.xtreme_online_stations W/dalvikvm: VFY: unable to find class referenced in signature (Landroid/view/SearchEvent;)
04-13 10:24:28.279 5845-5845/com.example.tony.xtreme_online_stations I/dalvikvm: Could not find method android.view.Window$Callback.onSearchRequested, referenced from method android.support.v7.view.WindowCallbackWrapper.onSearchRequested
04-13 10:24:28.279 5845-5845/com.example.tony.xtreme_online_stations W/dalvikvm: VFY: unable to resolve interface method 16008: Landroid/view/Window$Callback;.onSearchRequested (Landroid/view/SearchEvent;)Z
04-13 10:24:28.279 5845-5845/com.example.tony.xtreme_online_stations D/dalvikvm: VFY: replacing opcode 0x72 at 0x0002
04-13 10:24:28.279 5845-5845/com.example.tony.xtreme_online_stations I/dalvikvm: Could not find method android.view.Window$Callback.onWindowStartingActionMode, referenced from method android.support.v7.view.WindowCallbackWrapper.onWindowStartingActionMode
04-13 10:24:28.279 5845-5845/com.example.tony.xtreme_online_stations W/dalvikvm: VFY: unable to resolve interface method 16012: Landroid/view/Window$Callback;.onWindowStartingActionMode (Landroid/view/ActionMode$Callback;I)Landroid
 
Tony fig
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
/view/ActionMode;
04-13 10:24:28.279 5845-5845/com.example.tony.xtreme_online_stations D/dalvikvm: VFY: replacing opcode 0x72 at 0x0002
04-13 10:24:28.279 5845-5845/com.example.tony.xtreme_online_stations I/dalvikvm: Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.widget.TintTypedArray.getChangingConfigurations
04-13 10:24:28.279 5845-5845/com.example.tony.xtreme_online_stations W/dalvikvm: VFY: unable to resolve virtual method 706: Landroid/content/res/TypedArray;.getChangingConfigurations ()I
04-13 10:24:28.279 5845-5845/com.example.tony.xtreme_online_stations D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
04-13 10:24:28.287 5845-5845/com.example.tony.xtreme_online_stations I/dalvikvm: Could not find method android.content.res.TypedArray.getType, referenced from method android.support.v7.widget.TintTypedArray.getType
04-13 10:24:28.287 5845-5845/com.example.tony.xtreme_online_stations W/dalvikvm: VFY: unable to resolve virtual method 728: Landroid/content/res/TypedArray;.getType (I)I
04-13 10:24:28.287 5845-5845/com.example.tony.xtreme_online_stations D/dalvikvm: VFY: replacing opcode 0x6e at 0x0008
04-13 10:24:28.315 5845-5845/com.example.tony.xtreme_online_stations I/dalvikvm: Could not find method android.content.Context.createDeviceProtectedStorageContext, referenced from method android.support.v4.content.ContextCompat.createDeviceProtectedStorageContext
04-13 10:24:28.315 5845-5845/com.example.tony.xtreme_online_stations W/dalvikvm: VFY: unable to resolve virtual method 485: Landroid/content/Context;.createDeviceProtectedStorageContext ()Landroid/content/Context;
04-13 10:24:28.315 5845-5845/com.example.tony.xtreme_online_stations D/dalvikvm: VFY: replacing opcode 0x6e at 0x0006
04-13 10:24:28.315 5845-5845/com.example.tony.xtreme_online_stations I/dalvikvm: Could not find method android.content.Context.getCodeCacheDir, referenced from method android.support.v4.content.ContextCompat.getCodeCacheDir
04-13 10:24:28.315 5845-5845/com.example.tony.xtreme_online_stations W/dalvikvm: VFY: unable to resolve virtual method 491: Landroid/content/Context;.getCodeCacheDir ()Ljava/io/File;
04-13 10:24:28.315 5845-5845/com.example.tony.xtreme_online_stations D/dalvikvm: VFY: replacing opcode 0x6e at 0x0006
04-13 10:24:28.315 5845-5845/com.example.tony.xtreme_online_stations I/dalvikvm: Could not find method android.content.Context.getColor, referenced from method android.support.v4.content.ContextCompat.getColor
04-13 10:24:28.315 5845-5845/com.example.tony.xtreme_online_stations W/dalvikvm: VFY: unable to resolve virtual method 492: Landroid/content/Context;.getColor (I)I

 
Tony fig
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
04-13 10:24:28.315 5845-5845/com.example.tony.xtreme_online_stations D/dalvikvm: VFY: replacing opcode 0x6e at 0x0006
04-13 10:24:28.315 5845-5845/com.example.tony.xtreme_online_stations I/dalvikvm: Could not find method android.content.Context.getColorStateList, referenced from method android.support.v4.content.ContextCompat.getColorStateList
04-13 10:24:28.315 5845-5845/com.example.tony.xtreme_online_stations W/dalvikvm: VFY: unable to resolve virtual method 493: Landroid/content/Context;.getColorStateList (I)Landroid/content/res/ColorStateList;
04-13 10:24:28.315 5845-5845/com.example.tony.xtreme_online_stations D/dalvikvm: VFY: replacing opcode 0x6e at 0x0006
04-13 10:24:28.315 5845-5845/com.example.tony.xtreme_online_stations I/dalvikvm: Could not find method android.content.Context.getDataDir, referenced from method android.support.v4.content.ContextCompat.getDataDir
04-13 10:24:28.315 5845-5845/com.example.tony.xtreme_online_stations W/dalvikvm: VFY: unable to resolve virtual method 495: Landroid/content/Context;.getDataDir ()Ljava/io/File;
04-13 10:24:28.315 5845-5845/com.example.tony.xtreme_online_stations D/dalvikvm: VFY: replacing opcode 0x6e at 0x0006
04-13 10:24:28.315 5845-5845/com.example.tony.xtreme_online_stations I/dalvikvm: Could not find method android.content.Context.getDrawable, referenced from method android.support.v4.content.ContextCompat.getDrawable
04-13 10:24:28.315 5845-5845/com.example.tony.xtreme_online_stations W/dalvikvm: VFY: unable to resolve virtual method 496: Landroid/content/Context;.getDrawable (I)Landroid/graphics/drawable/Drawable;
04-13 10:24:28.315 5845-5845/com.example.tony.xtreme_online_stations D/dalvikvm: VFY: replacing opcode 0x6e at 0x0006
04-13 10:24:28.315 5845-5845/com.example.tony.xtreme_online_stations I/dalvikvm: Could not find method android.content.Context.getExternalCacheDirs, referenced from method android.support.v4.content.ContextCompat.getExternalCacheDirs
04-13 10:24:28.315 5845-5845/com.example.tony.xtreme_online_stations W/dalvikvm: VFY: unable to resolve virtual method 498: Landroid/content/Context;.getExternalCacheDirs ()[Ljava/io/File;
04-13 10:24:28.315 5845-5845/com.example.tony.xtreme_online_stations D/dalvikvm: VFY: replacing opcode 0x6e at 0x0006
04-13 10:24:28.315 5845-5845/com.example.tony.xtreme_online_stations I/dalvikvm: Could not find method android.content.Context.getExternalFilesDirs, referenced from method android.support.v4.content.ContextCompat.getExternalFilesDirs
04-13 10:24:28.315 5845-5845/com.example.tony.xtreme_online_stations W/dalvikvm: VFY: unable to resolve virtual method 500: Landroid/content/Context;.getExternalFilesDirs (Ljava/lang/String;)[Ljava/io/File;
04-13 10:24:28.315 5845-5845/com.example.tony.xtreme_online_stations D/dalvikvm: VFY: replacing opcode 0x6e at 0x0006
04-13 10:24:28.319 5845-5845/com.example.tony.xtreme_online_stations I/dalvikvm: Could not find method android.content.Context.getNoBackupFilesDir, referenced from method android.support.v4.content.ContextCompat.getNoBackupFilesDir
04-13 10:24:28.319 5845-5845/com.example.tony.xtreme_online_stations W/dalvikvm: VFY: unable to resolve virtual method 503: Landroid/content/Context;.getNoBackupFilesDir ()Ljava/io/File;
04-13 10:24:28.319 5845-5845/com.example.tony.xtreme_online_stations D/dalvikvm: VFY: replacing opcode 0x6e at 0x0006
04-13 10:24:28.319 5845-5845/com.example.tony.xtreme_online_stations I/dalvikvm: Could not find method android.content.Context.getObbDirs, referenced from method android.support.v4.content.ContextCompat.getObbDirs
04-13 10:24:28.323 5845-5845/com.example.tony.xtreme_online_stations W/dalvikvm: VFY: unable to resolve virtual method 505: Landroid/content/Context;.getObbDirs ()[Ljava/io/File;
04-13 10:24:28.323 5845-5845/com.example.tony.xtreme_online_stations D/dalvikvm: VFY: replacing opcode 0x6e at 0x0006
04-13 10:24:28.323 5845-5845/com.example.tony.xtreme_online_stations I/dalvikvm: Could not find method android.content.Context.isDeviceProtectedStorage, referenced from method android.support.v4.content.ContextCompat.isDeviceProtectedStorage
04-13 10:24:28.323 5845-5845/com.example.tony.xtreme_online_stations W/dalvikvm: VFY: unable to resolve virtual method 516: Landroid/content/Context;.isDeviceProtectedStorage ()Z
04-13 10:24:28.323 5845-5845/com.example.tony.xtreme_online_stations D/dalvikvm: VFY: replacing opcode 0x6e at 0x0006
04-13 10:24:28.323 5845-5845/com.example.tony.xtreme_online_stations I/dalvikvm: Could not find method android.content.Context.startForegroundService, referenced from method android.support.v4.content.ContextCompat.startForegroundService
04-13 10:24:28.323 5845-5845/com.example.tony.xtreme_online_stations W/dalvikvm: VFY: unable to resolve virtual method 531: Landroid/content/Context;.startForegroundService (Landroid/content/Intent;)Landroid/content/ComponentName;
04-13 10:24:28.323 5845-5845/com.example.tony.xtreme_online_stations D/dalvikvm: VFY: replacing opcode 0x6e at 0x0006
04-13 10:24:28.375 5845-5845/com.example.tony.xtreme_online_stations D/dalvikvm: GC_FOR_ALLOC freed 161K, 3% free 10843K/11143K, paused 4ms, total 14ms
04-13 10:24:28.379 5845-5845/com.example.tony.xtreme_online_stations I/dalvikvm-heap: Grow heap (frag case) to 11.226MB for 590492-byte allocation
04-13 10:24:28.395 5845-5850/com.example.tony.xtreme_online_stations D/dalvikvm: GC_CONCURRENT freed 2K, 4% free 11417K/11783K, paused 12ms+0ms, total 16ms
04-13 10:24:28.403 5845-5845/com.example.tony.xtreme_online_stations D/dalvikvm: GC_FOR_ALLOC freed 0K, 4% free 11417K/11783K, paused 3ms, total 3ms
04-13 10:24:28.403 5845-5845/com.example.tony.xtreme_online_stations I/dalvikvm-heap: Grow heap (frag case) to 13.476MB for 2361932-byte allocation
04-13 10:24:28.423 5845-5850/com.example.tony.xtreme_online_stations D/dalvikvm: GC_CONCURRENT freed 0K, 4% free 13724K/14151K, paused 1ms+2ms, total 8ms
04-13 10:24:28.431 5845-5845/com.example.tony.xtreme_online_stations I/dalvikvm: Could not find method android.view.ViewGroup$MarginLayoutParams.resolveLayoutDirection, referenced from method
 
Tony fig
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
android.support.constraint.ConstraintLayout$LayoutParams.resolveLayoutDirection
04-13 10:24:28.431 5845-5845/com.example.tony.xtreme_online_stations W/dalvikvm: VFY: unable to resolve virtual method 15854: Landroid/view/ViewGroup$MarginLayoutParams;.resolveLayoutDirection (I)V
04-13 10:24:28.431 5845-5845/com.example.tony.xtreme_online_stations D/dalvikvm: VFY: replacing opcode 0x6f at 0x0002
04-13 10:24:28.451 5845-5845/com.example.tony.xtreme_online_stations D/dalvikvm: GC_FOR_ALLOC freed 589K, 7% free 13171K/14151K, paused 16ms, total 16ms
04-13 10:24:28.451 5845-5845/com.example.tony.xtreme_online_stations I/dalvikvm-heap: Grow heap (frag case) to 13.916MB for 1027532-byte allocation
04-13 10:24:28.467 5845-5850/com.example.tony.xtreme_online_stations D/dalvikvm: GC_CONCURRENT freed 0K, 7% free 14174K/15175K, paused 11ms+1ms, total 15ms
04-13 10:24:28.491 5845-5845/com.example.tony.xtreme_online_stations D/dalvikvm: GC_FOR_ALLOC freed <1K, 7% free 14174K/15175K, paused 14ms, total 14ms
04-13 10:24:28.511 5845-5845/com.example.tony.xtreme_online_stations I/dalvikvm-heap: Grow heap (frag case) to 17.835MB for 4110092-byte allocation
04-13 10:24:28.603 5845-5850/com.example.tony.xtreme_online_stations D/dalvikvm: GC_CONCURRENT freed 0K, 6% free 18188K/19207K, paused 11ms+0ms, total 66ms
04-13 10:24:28.687 5845-5845/com.example.tony.xtreme_online_stations D/libEGL: loaded /system/lib/egl/libEGL_genymotion.so
                                                                             
                                                                              [ 04-13 10:24:28.687  5845: 5845 D/         ]
                                                                              HostConnection::get() New Host Connection established 0xb8961790, tid 5845
04-13 10:24:28.735 5845-5845/com.example.tony.xtreme_online_stations E/SocketStream: readFully was waiting for 51328 bytes, got 28960
04-13 10:24:28.735 5845-5845/com.example.tony.xtreme_online_stations D/libEGL: loaded /system/lib/egl/libGLESv1_CM_genymotion.so
04-13 10:24:28.735 5845-5845/com.example.tony.xtreme_online_stations D/libEGL: loaded /system/lib/egl/libGLESv2_genymotion.so
04-13 10:24:28.823 5845-5845/com.example.tony.xtreme_online_stations W/EGL_genymotion: eglSurfaceAttrib not implemented
04-13 10:24:28.839 5845-5845/com.example.tony.xtreme_online_stations D/OpenGLRenderer: Enabling debug mode 0
04-13 10:24:28.839 5845-5845/com.example.tony.xtreme_online_stations I/dalvikvm: Could not find method android.widget.TextView.getAutoSizeMaxTextSize, referenced from method android.support.v7.widget.AppCompatTextView.getAutoSizeMaxTextSize
04-13 10:24:28.839 5845-5845/com.example.tony.xtreme_online_stations W/dalvikvm: VFY: unable to resolve virtual method 16801: Landroid/widget/TextView;.getAutoSizeMaxTextSize ()I
04-13 10:24:28.839 5845-5845/com.example.tony.xtreme_online_stations D/dalvikvm: VFY: replacing opcode 0x6f at 0x0006
04-13 10:24:28.839 5845-5845/com.example.tony.xtreme_online_stations I/dalvikvm: Could not find method android.widget.TextView.getAutoSizeMinTextSize, referenced from method android.support.v7.widget.AppCompatTextView.getAutoSizeMinTextSize
04-13 10:24:28.839 5845-5845/com.example.tony.xtreme_online_stations W/dalvikvm: VFY: unable to resolve virtual method 16802: Landroid/widget/TextView;.getAutoSizeMinTextSize ()I
04-13 10:24:28.839 5845-5845/com.example.tony.xtreme_online_stations D/dalvikvm: VFY: replacing opcode 0x6f at 0x0006
04-13 10:24:28.839 5845-5845/com.example.tony.xtreme_online_stations I/dalvikvm: Could not find method android.widget.TextView.getAutoSizeStepGranularity, referenced from method android.support.v7.widget.AppCompatTextView.getAutoSizeStepGranularity
04-13 10:24:28.839 5845-5845/com.example.tony.xtreme_online_stations W/dalvikvm: VFY: unable to resolve virtual method 16803: Landroid/widget/TextView;.getAutoSizeStepGranularity ()I
04-13 10:24:28.839 5845-5845/com.example.tony.xtreme_online_stations D/dalvikvm: VFY: replacing opcode 0x6f at 0x0006
04-13 10:24:28.839 5845-5845/com.example.tony.xtreme_online_stations I/dalvikvm: Could not find method android.widget.TextView.getAutoSizeTextAvailableSizes, referenced from method android.support.v7.widget.AppCompatTextView.getAutoSizeTextAvailableSizes
04-13 10:24:28.839 5845-5845/com.example.tony.xtreme_online_stations W/dalvikvm: VFY: unable to resolve virtual method 16804: Landroid/widget/TextView;.getAutoSizeTextAvailableSizes ()[I
04-13 10:24:28.839 5845-5845/com.example.tony.xtreme_online_stations D/dalvikvm: VFY: replacing opcode 0x6f at 0x0006
04-13 10:24:28.839 5845-5845/com.example.tony.xtreme_online_stations I/dalvikvm: Could not find method android.widget.TextView.getAutoSizeTextType, referenced from method android.support.v7.widget.AppCompatTextView.getAutoSizeTextType
04-13 10:24:28.839 5845-5845/com.example.tony.xtreme_online_stations W/dalvikvm: VFY: unable to resolve virtual method 16805: Landroid/widget/TextView;.getAutoSizeTextType ()I
04-13 10:24:28.839 5845-5845/com.example.tony.xtreme_online_stations D/dalvikvm: VFY: replacing opcode 0x6f at 0x0008
04-13 10:24:28.839 5845-5845/com.example.tony.xtreme_online_stations I/dalvikvm: Could not find method android.widget.TextView.setAutoSizeTextTypeUniformWithConfiguration, referenced from method android.support.v7.widget.AppCompatTextView.setAutoSizeTextTypeUniformWithConfiguration
04-13 10:24:28.839 5845-5845/com.example.tony.xtreme_online_stations W/dalvikvm: VFY: unable to resolve virtual method 16848: Landroid/widget/TextView;.setAutoSizeTextTypeUniformWithConfiguration (IIII)V
04-13 10:24:28.839 5845-5845/com.example.tony.xtreme_online_stations D/dalvikvm: VFY: replacing opcode 0x6f at 0x0006
04-13 10:24:28.839 5845-5845/com.example.tony.xtreme_online_stations I/dalvikvm: Could not find method android.widget.TextView.setAutoSizeTextTypeUniformWithPresetSizes, referenced from method android.support.v7.widget.AppCompatTextView.setAutoSizeTextTypeUniformWithPresetSizes
04-13 10:24:28.839 5845-5845/com.example.tony.xtreme_online_stations W/dalvikvm: VFY: unable to resolve virtual method 16849: Landroid/widget/TextView;.setAutoSizeTextTypeUniformWithPresetSizes ([II)V
04-13 10:24:28.839 5845-5845/com.example.tony.xtreme_online_stations D/dalvikvm: VFY: replacing opcode 0x6f at 0x0006
04-13 10:24:28.839 5845-5845/com.example.tony.xtreme_online_stations I/dalvikvm: Could not find method android.widget.TextView.setAutoSizeTextTypeWithDefaults, referenced from method android.support.v7.widget.AppCompatTextView.setAutoSizeTextTypeWithDefaults
04-13 10:24:28.839 5845-5845/com.example.tony.xtreme_online_stations W/dalvikvm: VFY: unable to resolve virtual method 16850: Landroid/widget/TextView;.setAutoSizeTextTypeWithDefaults (I)V
04-13 10:24:28.839 5845-5845/com.example.tony.xtreme_online_stations D/dalvikvm: VFY: replacing opcode 0x6f at 0x0006
 
Tony fig
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
04-13 10:24:28.839 5845-5845/com.example.tony.xtreme_online_stations I/dalvikvm: Could not find method android.content.res.Resources.getDrawable, referenced from method android.support.v7.widget.ResourcesWrapper.getDrawable
04-13 10:24:28.839 5845-5845/com.example.tony.xtreme_online_stations W/dalvikvm: VFY: unable to resolve virtual method 669: Landroid/content/res/Resources;.getDrawable (ILandroid/content/res/Resources$Theme;)Landroid/graphics/drawable/Drawable;
04-13 10:24:28.839 5845-5845/com.example.tony.xtreme_online_stations D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
04-13 10:24:28.839 5845-5845/com.example.tony.xtreme_online_stations I/dalvikvm: Could not find method android.content.res.Resources.getDrawableForDensity, referenced from method android.support.v7.widget.ResourcesWrapper.getDrawableForDensity
04-13 10:24:28.839 5845-5845/com.example.tony.xtreme_online_stations W/dalvikvm: VFY: unable to resolve virtual method 671: Landroid/content/res/Resources;.getDrawableForDensity (IILandroid/content/res/Resources$Theme;)Landroid/graphics/drawable/Drawable;
04-13 10:24:28.839 5845-5845/com.example.tony.xtreme_online_stations D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
04-13 10:24:28.839 5845-5845/com.example.tony.xtreme_online_stations I/dalvikvm: Could not find method android.widget.TextView.getAutoSizeStepGranularity, referenced from method android.support.v7.widget.AppCompatTextHelper.loadFromAttributes
04-13 10:24:28.839 5845-5845/com.example.tony.xtreme_online_stations W/dalvikvm: VFY: unable to resolve virtual method 16803: Landroid/widget/TextView;.getAutoSizeStepGranularity ()I
04-13 10:24:28.839 5845-5845/com.example.tony.xtreme_online_stations D/dalvikvm: VFY: replacing opcode 0x6e at 0x0197
04-13 10:24:28.843 5845-5845/com.example.tony.xtreme_online_stations I/dalvikvm: Could not find method android.text.StaticLayout$Builder.obtain, referenced from method android.support.v7.widget.AppCompatTextViewAutoSizeHelper.createStaticLayoutForMeasuring
04-13 10:24:28.843 5845-5845/com.example.tony.xtreme_online_stations W/dalvikvm: VFY: unable to resolve static method 15279: Landroid/text/StaticLayout$Builder;.obtain (Ljava/lang/CharSequence;IILandroid/text/TextPaint;I)Landroid/text/StaticLayout$Builder;
04-13 10:24:28.843 5845-5845/com.example.tony.xtreme_online_stations D/dalvikvm: VFY: replacing opcode 0x71 at 0x0014
04-13 10:24:28.843 5845-5845/com.example.tony.xtreme_online_stations I/dalvikvm: Could not find method android.widget.TextView.isInLayout, referenced from method android.support.v7.widget.AppCompatTextViewAutoSizeHelper.setRawTextSize
04-13 10:24:28.843 5845-5845/com.example.tony.xtreme_online_stations W/dalvikvm: VFY: unable to resolve virtual method 16840: Landroid/widget/TextView;.isInLayout ()Z
04-13 10:24:28.843 5845-5845/com.example.tony.xtreme_online_stations D/dalvikvm: VFY: replacing opcode 0x6e at 0x0021
04-13 10:24:28.843 5845-5845/com.example.tony.xtreme_online_stations I/dalvikvm: Could not find method android.content.Context.getColorStateList, referenced from method android.support.v7.content.res.AppCompatResources.getColorStateList
04-13 10:24:28.843 5845-5845/com.example.tony.xtreme_online_stations W/dalvikvm: VFY: unable to resolve virtual method 493: Landroid/content/Context;.getColorStateList (I)Landroid/content/res/ColorStateList;
04-13 10:24:28.843 5845-5845/com.example.tony.xtreme_online_stations D/dalvikvm: VFY: replacing opcode 0x6e at 0x0006
04-13 10:24:28.895 5845-5845/com.example.tony.xtreme_online_stations D/OpenGLRenderer: TextureCache::get: create texture(0xb8976890): name, size, mSize = 1, 2361920, 2361920
04-13 10:24:28.999 5845-5845/com.example.tony.xtreme_online_stations D/OpenGLRenderer: TextureCache::get: create texture(0xb8970cf0): name, size, mSize = 2, 4110080, 6472000
04-13 10:24:29.003 5845-5845/com.example.tony.xtreme_online_stations D/OpenGLRenderer: TextureCache::get: create texture(0xb8951f68): name, size, mSize = 3, 16, 6472016
04-13 10:24:29.039 5845-5845/com.example.tony.xtreme_online_stations D/OpenGLRenderer: TextureCache::get: create texture(0xb8968670): name, size, mSize = 5, 1600, 6473616
04-13 10:24:29.039 5845-5845/com.example.tony.xtreme_online_stations D/OpenGLRenderer: TextureCache::get: create texture(0xb8979450): name, size, mSize = 6, 4096, 6477712
04-13 10:25:01.895 5845-5845/com.example.tony.xtreme_online_stations D/OpenGLRenderer: TextureCache::get: create texture(0xb8955788): name, size, mSize = 63, 576, 6478288
04-13 10:25:01.951 5845-5845/com.example.tony.xtreme_online_stations E/MediaPlayer: start called in state 1
04-13 10:25:01.951 5845-5845/com.example.tony.xtreme_online_stations E/MediaPlayer: error (-38, 0)
04-13 10:25:07.075 5845-5845/com.example.tony.xtreme_online_stations I/Choreographer: Skipped 306 frames!  The application may be doing too much work on its main thread.
04-13 10:25:07.083 5845-5845/com.example.tony.xtreme_online_stations E/MediaPlayer: Error (-38,0)
04-13 10:25:13.067 5845-5872/com.example.tony.xtreme_online_stations D/false: onCancelled() called
04-13 10:25:13.067 5845-5872/com.example.tony.xtreme_online_stations I/System.out: len=4096 at time=1523615113070
04-13 10:25:13.067 5845-5872/com.example.tony.xtreme_online_stations I/System.out: len=4096 at time=1523615113071
04-13 10:25:13.067 5845-5872/com.example.tony.xtreme_online_stations I/System.out: len=4096 at time=1523615113071
04-13 10:25:13.067 5845-5872/com.example.tony.xtreme_online_stations I/System.out: len=744 at time=1523615113071
04-13 10:25:13.091 5845-5872/com.example.tony.xtreme_online_stations I/System.out: len=1448 at time=1523615113093
04-13 10:25:13.091 5845-5872/com.example.tony.xtreme_online_stations I/System.out: len=1448 at time=1523615113094
04-13 10:25:13.259 5845-5872/com.example.tony.xtreme_online_stations I/System.out: len=791 at time=1523615113262
04-13 10:25:13.259 5845-5872/com.example.tony.xtreme_online_stations I/System.out: len=4096 at time=1523615113262
04-13 10:25:13.259 5845-5872/com.example.tony.xtreme_online_stations I/System.out: len=248 at time=1523615113263
 
Norm Radder
Rancher
Posts: 3350
33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

04-13 10:25:13.067 5845-5872/com.example.tony.xtreme_online_stations D/false: onCancelled() called  


What is "onCancelled()"?
Was that the value returned by the isCancelled() method?  Where was the print statement located in the code?
What about the value inside the while loop?


Only the lines with " I/System.out" need to be copied and pasted here.  Those are the lines from the System.out.println statements that were added for debugging?
 
Tony fig
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"onCancelled()" is the print out of OnCancelled but it only detects that print out when I start the download. if I try to cancel it it wont detect it.
 
Tony fig
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Log.d( String.valueOf( isCancelled() ), "onCancelled() called");
                           
here is the print out for onCancelled but it only detects this when I start the download and when I try to cancel it

04-13 10:25:13.067 5845-5872/com.example.tony.xtreme_online_stations D/false: onCancelled() called



                           while ((len = is.read(buffer)) > 0 && endTime > System.currentTimeMillis() && !isCancelled()
                                   ) {

                               if (isCancelled()) break;
                               outstream.write(buffer, 0, len);
                               System.out.println("len="+len  + " at time="+  System.currentTimeMillis());
                               Here is the print out for len


04-13 10:25:13.067 5845-5872/com.example.tony.xtreme_online_stations I/System.out: len=4096 at time=1523615113070
04-13 10:25:13.067 5845-5872/com.example.tony.xtreme_online_stations I/System.out: len=4096 at time=1523615113071
04-13 10:25:13.067 5845-5872/com.example.tony.xtreme_online_stations I/System.out: len=4096 at time=1523615113071
04-13 10:25:13.067 5845-5872/com.example.tony.xtreme_online_stations I/System.out: len=744 at time=1523615113071
04-13 10:25:13.091 5845-5872/com.example.tony.xtreme_online_stations I/System.out: len=1448 at time=1523615113093
04-13 10:25:13.091 5845-5872/com.example.tony.xtreme_online_stations I/System.out: len=1448 at time=1523615113094
04-13 10:25:13.259 5845-5872/com.example.tony.xtreme_online_stations I/System.out: len=791 at time=1523615113262
04-13 10:25:13.259 5845-5872/com.example.tony.xtreme_online_stations I/System.out: len=4096 at time=1523615113262
04-13 10:25:13.259 5845-5872/com.example.tony.xtreme_online_stations I/System.out: len=248 at time=1523615113263
04-13 10:25:13.263 5845-5872/com.example.tony.xtreme_online_stations I/System.out: len=4096 at time=1523615113266
04-13 10:25:13.263 5845-5872/com.example.tony.xtreme_online_stations I/System.out: len=4096 at time=1523615113267
04-13 10:25:13.263 5845-5872/com.example.tony.xtreme_online_stations I/System.out: len=4096 at time=1523615113267
04-13 10:25:13.267 5845-5872/com.example.tony.xtreme_online_stations I/System.out: len=2192 at time=1523615113267
04-13 10:25:13.295 5845-5872/com.example.tony.xtreme_online_stations I/System.out: len=2896 at time=1523615113297
04-13 10:25:13.303 5845-5872/com.example.tony.xtreme_online_stations I/System.out: len=4096 at time=1523615113305
04-13 10:25:13.303 5845-5872/com.example.tony.xtreme_online_stations I/System.out: len=4096 at time=1523615113305
04-13 10:25:13.303 5845-5872/com.example.tony.xtreme_online_stations I/System.out: len=4096 at time=1523615113306
04-13 10:25:13.303 5845-5872/com.example.tony.xtreme_online_stations I/System.out: len=2192 at time=1523615113306
04-13 10:25:13.311 5845-5872/com.example.tony.xtreme_online_stations I/System.out: len=371 at time=1523615113313



                           }
 
Tony fig
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when I try to cancele it wont download...
 
Tony fig
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when I try to cancel it, it wont detect it.
 
Tony fig
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry about the confusion but I can find a edit button on here.
 
Norm Radder
Rancher
Posts: 3350
33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where are the print outs from before and after the call to the cancel() method?

Mixing the use of Log and System.out.println is confusing.

The posted code does not show where the value of isCancelled() was printed.  It should be printed before, inside of and after the while loop.
 
Prasad Saya
Rancher
Posts: 506
15
Java Notepad
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Tony fig wrote:I have figured out how to put together the AsymcTask to cancel it but the cancel isn't working. can you tell me why its not. here is by code




In the above code I'd like to make two points:

(1)
I think the AsycTask's cancel() method should not be in the onCancelled() method (the line 11). The AsyncTask's override method onCancelled() is executed when there the async task is cancelled (see the cancel method definition's link below).

Here are links to Android's documentation on cancel and onCancelled methods:

Cancel - Calling this method will result in onCancelled(Object) being invoked...: https://developer.android.com/reference/android/os/AsyncTask.html#cancel(boolean)

onCancelled - https://developer.android.com/reference/android/os/AsyncTask.html#onCancelled(Result)

(2)
Referring to line 23: As I had mentioned earlier in this post (see the reference  below), the AsyncTask's cancel() method should be invoked from elsewhere, like a "cancel" button's listener method.

Prasad Saya wrote:

Tony fig wrote:its a simple question that im asking all i want to know is how can I cancel the download?



It depends on your app's functionality. In case you have a cancel task button, the button's listener method can cancel the async task. Also, note that the cancel can also be called from an Activity's callback method (e.g., onStop method).



 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!