I've this string
227305593149516.jpg;221563849532915.3gp;
I split each file name with ; charecter as you can see .I use this code inside my activity to make them apart :
mystring="227305593149516.jpg;221563849532915.3gp;";
StringTokenizer tokenizer = new StringTokenizer(mystring, ";");
while (tokenizer.hasMoreTokens()) {
String token = tokenizer.nextToken();
if(!token.contains(".3gp")){//aks bud
imges[cimage]=token;
cimage++;
}else{//film bud
if(cvide==1)
video1=token;
else
video2=token;
cvide++;
}
}
It's very strange ,I run this code on emulator and 2 other devices and it works find but I run the same app on another phone and it crashed , this is the log :
java.lang.ArrayIndexOutOfBoundsException: length=1; index=1
at com.arousshow.persiandesigners.AddDetails$GetContacts.onPostExecute(AddDetails.java:160)
at com.arousshow.persiandesigners.AddDetails$GetContacts.onPostExecute(AddDetails.java:1)
at android.os.AsyncTask.finish(AsyncTask.java:631)
at android.os.AsyncTask.access$600(AsyncTask.java:177)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:644)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4898)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
at dalvik.system.NativeStart.main(Native Method)
this is the line that make the app crashes (AddDetails.java:160) :
if(!token.contains(".3gp")){
the model phone is PHONE_MODEL = GT-I9300 and ANDROID_VERSION = 4.1.2 .
Could you help me ? Thanks
imges? because i thinkimges[cimage]=token;is the line makes the errorimgeshas length=1 and the conditioncontains(".3gp")applied on 2 entries so OP gots the error, though the current string does not show that 2 items matches the condition!