Home > Mobile >  Java. Lang. ArrayIndexOutOfBoundsException: length=0; The index=0
Java. Lang. ArrayIndexOutOfBoundsException: length=0; The index=0

Time:09-20

Launch crash 12:11:42. 03-11, 966, 7890, 7890 E AndroidRuntime: FATAL EXCEPTION: the main 12:11:42. 03-11, 966, 7890, 7890 E AndroidRuntime: Process: com. Microfield. StartUp, PID: 7890 03-11 12:11:42. 966, 7890, 7890 E AndroidRuntime: Java. Lang. RuntimeException: Unable to start the activity ComponentInfo {com. Microfield. StartUp/com. Microfield. StartUp. SplashMain} : Java. Lang. ArrayIndexOutOfBoundsException: length=0; index=0 03-11 12:11:42.966 7890 7890 E AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2747) 03-11 12:11:42.966 7890 7890 E AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2808) 03-11 12:11:42.966 7890 7890 E AndroidRuntime: at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:4626) 03-11 12:11:42.966 7890 7890 E AndroidRuntime: at android.app.ActivityThread.-wrap19(ActivityThread.java) 03-11 12:11:42.966 7890 7890 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1549) 03-11 12:11:42.966 7890 7890 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102) 03-11 12:11:42.966 7890 7890 E AndroidRuntime: at android.os.Looper.loop(Looper.java:165) 03-11 12:11:42.966 7890 7890 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:6375) 03-11 12:11:42.966 7890 7890 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method) 03-11 12:11:42.966 7890 7890 E AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912) 03-11 12:11:42.966 7890 7890 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:802) 03-11 12:11:42.966 7890 7890 E AndroidRuntime: Caused by: java.lang.ArrayIndexOutOfBoundsException: length=0; The index=0



SplashMain. Class

 public class SplashMain extends AppCompatActivity {
@ Override
Protected void onCreate (@ Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
The setContentView (R.l ayout. Welcome);
DateBase. DataBase helper=new dateBase. DataBase (this, "app_record", 1);
Helper. Action_sql (" create table if not exists app_record (id integer primary key autoincrement, packageName text, activity text) ");
If (helper. Query_Num (" app_record ")==0) {
String STR="air. TV. Douyu. Android, com. Duowan. Kiwi, com. Taobao. Bing".
String str2="air. TV. Douyu. Android, com. Duowan. Kiwi. Adsplash. The AdSplashActivity, com. Taobao. SNS. App. Advertise. AdvertiseActivity";
String [] list1=STR. The split (", "), list2=str2. Split (", ");
for (int i=0; i ContentValues CV=new ContentValues ();
CV. Put (" packageName ", list1 [I]);
CV. Put (" activity ", list2 [I]);
Helper. Insert (" app_record ", CV);
}
}
Helper. The close ();
CheckPermission ();
}

//inspection authority
Private void checkPermission () {
//check permissions access (android6.0 and above system may be off by default permissions, and didn't tip)
if (! API. Query_qx (this)) {
ActivityCompat. RequestPermissions (this, new String [] {
The Manifest. Permission. READ_EXTERNAL_STORAGE, Manifest. Permission. WRITE_EXTERNAL_STORAGE,
The Manifest. Permission. RECORD_AUDIO, Manifest. Permission. READ_PHONE_STATE
}, 1);
} else {
DOS ();
}
}

Public void onRequestPermissionsResult (int requestCode, @ NonNull String [] permissions,
@ NonNull int [] grantResults) {
If (requestCode==1) {
If (grantResults [0]==PackageManager. PERMISSION_GRANTED) {
DOS ();
} else {
Final MyDialog MyDialog=new MyDialog (this);
MyDialog. The show ();
MyDialog. SetIcon (getDrawable (R.d rawable. Ic_flash_on_black_24dp));
MyDialog. SetTitle (" warm prompt ");
MyDialog. SetMessage (" insufficient privileges to could lead to problems in the process of using the software, whether into the software?" );
MyDialog. SetButton1 (" know ", new View. An OnClickListener () {
@ Override
Public void onClick (View v) {
MyDialog. Cancel ();
DOS ();
}
});
}
}
}

Private void DOS () {
If (API. Query_setting (this, "is_hide")==0) {
StartActivity (new Intent (). SetClass (this, MainActivity. Class). AddFlags (Intent. FLAG_ACTIVITY_NEW_DOCUMENT));
finish();
} else {
StartActivity (new Intent (). SetClass (this, MainActivity class));
finish();
}
}

}


Who knows what is the problem

CodePudding user response:

An array, the array is empty, you need to access the first element, sure there's no way. A good check code

CodePudding user response:

reference 1st floor BDMH response:
an array, the array is empty, you need to access the first element, sure there's no way and have a good check code

I put the onCreate checkPermission was left

CodePudding user response:

reference 1st floor BDMH response:
an array, the array is empty, you need to access the first element, sure there's no way and have a good check code

I put the onCreate checkPermission was left

CodePudding user response:

reference 1st floor BDMH response:
an array, the array is empty, you need to access the first element, sure there's no way and have a good check code

nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related