Hi
I will to show all device app icon in my app ,
but this ERROR ocurred :
Error occurred on line: 45 (Main)
java.lang.ArrayIndexOutOfBoundsException: length=0; index=0
at mypackage.mymanager.main._activity_create(main.java:405)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:703)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:337)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:247)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
at mypackage.mymanager.main.afterFirstLayout(main.java:102)
at mypackage.mymanager.main.access$000(main.java:17)
at mypackage.mymanager.main$WaitForLayout.run(main.java:80)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5102)
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:797)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:564)
at dalvik.system.NativeStart.main(Native Method)
I will to show all device app icon in my app ,
B4X:
Sub Globals
Dim LISTpackages,LISTpackages2 As List
Dim listviewAPP As ListView
Dim packageManager1 As PackageManager
Dim imageview() As ImageView
Dim L As String
End Sub
Sub Activity_Create(FirstTime As Boolean)
LISTpackages.Initialize
LISTpackages2.Initialize
LISTpackages = packageManager1.GetInstalledPackages
For i = 0 To LISTpackages.Size - 1
If GetType(packageManager1.GetApplicationIcon(LISTpackages.Get(i))) = "android.graphics.drawable.BitmapDrawable" Then ' "android.graphics.drawable.BitmapDrawable"
Dim d As BitmapDrawable = packageManager1.GetApplicationIcon(LISTpackages.Get(i))
imageview(i).Initialize("imageview"&i) 'this line is 45 ERROR occured in this line
Activity.AddView(imageview(i),i*4%x,i*4%y, i*4%x,i*4%y)
imageview(i).Background=d
Else
End If
Next
End Sub
but this ERROR ocurred :
Error occurred on line: 45 (Main)
java.lang.ArrayIndexOutOfBoundsException: length=0; index=0
at mypackage.mymanager.main._activity_create(main.java:405)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:703)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:337)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:247)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
at mypackage.mymanager.main.afterFirstLayout(main.java:102)
at mypackage.mymanager.main.access$000(main.java:17)
at mypackage.mymanager.main$WaitForLayout.run(main.java:80)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5102)
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:797)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:564)
at dalvik.system.NativeStart.main(Native Method)