karthikbabucv
Lurker
I am facing some issue in my code, can anyone please help me on this, please find the below crash which i am getting,
Fatal Exception: java.lang.ArrayIndexOutOfBoundsException: length=0; index=0
at com.***.in.***.onRequestPermissionsResult(***.java:476)
at android.app.Activity.requestPermissions(Activity.java:4290)
at com.***.in.***.startGeofence(***.java:450)
at com.***.in.***.FunctionCall(***.java:332)
at com.***.in.***.LoadConstants(***.java:238)
at com.***.in.***.access$100(***.java:75)
at com.***.in.***$5$1.run(***.java:267)
at android.os.Handler.handleCallback(Handler.java:754)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:163)
at android.app.ActivityThread.main(ActivityThread.java:6393)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:933)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)
Please find my code where the crash is happening,
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
requestPermissions(
new String[]{
Manifest.permission.ACCESS_FINE_LOCATION
},
4500);
}
@override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
if(requestCode != RESULT_CANCELED) {
if (requestCode == 4500) {
***(grantResults[0] == PackageManager.PERMISSION_GRANTED); - #Crash in this line#
} else {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
}
}
Note: This crash is not happening in all devices, only some devices like (ViVo, Redmi, Oppo) - that too specific with specific devices and OS this crash occurs.
Fatal Exception: java.lang.ArrayIndexOutOfBoundsException: length=0; index=0
at com.***.in.***.onRequestPermissionsResult(***.java:476)
at android.app.Activity.requestPermissions(Activity.java:4290)
at com.***.in.***.startGeofence(***.java:450)
at com.***.in.***.FunctionCall(***.java:332)
at com.***.in.***.LoadConstants(***.java:238)
at com.***.in.***.access$100(***.java:75)
at com.***.in.***$5$1.run(***.java:267)
at android.os.Handler.handleCallback(Handler.java:754)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:163)
at android.app.ActivityThread.main(ActivityThread.java:6393)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:933)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)
Please find my code where the crash is happening,
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
requestPermissions(
new String[]{
Manifest.permission.ACCESS_FINE_LOCATION
},
4500);
}
@override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
if(requestCode != RESULT_CANCELED) {
if (requestCode == 4500) {
***(grantResults[0] == PackageManager.PERMISSION_GRANTED); - #Crash in this line#
} else {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
}
}
Note: This crash is not happening in all devices, only some devices like (ViVo, Redmi, Oppo) - that too specific with specific devices and OS this crash occurs.