Info about +1 code

Asmoro

Active Member
Licensed User
Longtime User
Hi All,

I'm examine an error in FlickrView demo.

If I have a sub:

Code: Copy
Sub ImageUrlDone (Url As String)
   ivs(ImageIndex).Bitmap = HttpUtils.GetBitmap(Url)
   ivs(ImageIndex).Gravity = Gravity.FILL
   ImageIndex = ImageIndex + 1
End Sub

What the +1 means in this case, cause the error log says:

java.lang.ArrayIndexOutOfBoundsException

** Activity (main) Resume **
Starting Job: Main page
** Service (httputilsservice) Create **
** Service (httputilsservice) Start **
done parsing main page: 23
Starting Job: Images
** Service (httputilsservice) Start **
main_imageurldone (B4A line: 97)
ivs(ImageIndex).Bitmap = HttpUtils.GetBitmap(Url)
java.lang.ArrayIndexOutOfBoundsException
at anywheresoftware.b4a.samples.flickr.main._imageurldone(main.java:548)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:105)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:89)
at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:760)
at anywheresoftware.b4a.keywords.Common.CallSub2(Common.java:747)
at anywheresoftware.b4a.samples.flickr.httputilsservice._response_streamfinish(httputilsservice.java:336)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:105)
at anywheresoftware.b4a.BA$1.run(BA.java:210)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:3701)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:862)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)
at dalvik.system.NativeStart.main(Native Method)
java.lang.ArrayIndexOutOfBoundsException

If I delete the +1: all the images quickly went by.
And -1: one image will be displayed.

So why the +1 is working on the original FlickrView demo and
not in my Flickr test demo, causing an error.

The differences between the two are fetching the web url and "links.add"
 
The error is here

ArrayIndexOutOfBoundsException

What is in your Array(). How many fields?
How many images do you fetching?
If I understood correct you have changed web url so it is not anymore flickr so you are trying to fetch maybe more images than is declared in array.
 
Last edited:
Upvote 0
Hi Pluton,

Thanks helping me out.

It seems that the original FlickrView demo have 9 imageviews
in an array.

So I made a row of 3 x 3 on the website, and no errors came out.

Now I have to find out how to fetch another page with different images.
 
Upvote 0

Similar Threads

  • Locked
  • Article Article
Android Code Snippet Advertising id
Replies
19
Views
25K
Replies
16
Views
13K
  • Question Question
Android Question AutoScale Code Module
Replies
70
Views
65K
Back
Top