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; iContentValues 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 codeCodePudding user response: