Hello,
I not an expert in android coding but I know little bit, that's why I bought this app from a person. Unfortunately the app author was not giving supporting to me that's why Iam posting this issue here. So please help me, my new app was working fine in older versions but in android 6 and latest version it was stuck in splash screen. In older versions this splash screen was not working/showing. I have enabled the permission in android 6 but after enabling the permission it was stuck in the same screen. I have relaunched the app many time but the same error and same issue it was not go to second screen in android 6 version and not showing splash screen in other versions SO Any one can help me on this please help me. If you needed any other codes please mention in the reply I will update it here..
public class Splash extends AppCompatActivity {
public static final int MY_PERMISSIONS_REQUEST_WRITE_FIELS = 102;
AlertDialog dialog;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
getSupportActionBar().hide();
if (ContextCompat.checkSelfPermission(this,
android.Manifest.permission.WRITE_EXTERNAL_STORAGE)
!= PackageManager.PERMISSION_GRANTED ||
ContextCompat.checkSelfPermission(this,
android.Manifest.permission.INTERNET)
!= PackageManager.PERMISSION_GRANTED||
ContextCompat.checkSelfPermission(this,
android.Manifest.permission.READ_EXTERNAL_STORAGE)
!= PackageManager.PERMISSION_GRANTED||
ContextCompat.checkSelfPermission(this,
android.Manifest.permission.CAMERA)
!= PackageManager.PERMISSION_GRANTED||
ContextCompat.checkSelfPermission(this,
android.Manifest.permission.ACCESS_NETWORK_STATE)
!= PackageManager.PERMISSION_GRANTED||
ContextCompat.checkSelfPermission(this,
android.Manifest.permission.ACCESS_COARSE_LOCATION)
!= PackageManager.PERMISSION_GRANTED||
ContextCompat.checkSelfPermission(this,
android.Manifest.permission.ACCESS_FINE_LOCATION)
!= PackageManager.PERMISSION_GRANTED
) {
if (ActivityCompat.shouldShowRequestPermissionRationale(this,
Manifest.permission.WRITE_EXTERNAL_STORAGE) && ActivityCompat.shouldShowRequestPermissionRationale(this,
Manifest.permission.CAMERA) && ActivityCompat.shouldShowRequestPermissionRationale(this,
Manifest.permission.READ_EXTERNAL_STORAGE) && ActivityCompat.shouldShowRequestPermissionRationale(this,
Manifest.permission.INTERNET) && ActivityCompat.shouldShowRequestPermissionRationale(this,
Manifest.permission.ACCESS_NETWORK_STATE) && ActivityCompat.shouldShowRequestPermissionRationale(this,
Manifest.permission.ACCESS_COARSE_LOCATION) && ActivityCompat.shouldShowRequestPermissionRationale(this,
Manifest.permission.ACCESS_FINE_LOCATION)) {
go_next();
} else {
ActivityCompat.requestPermissions(this,
new String[]{
Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.INTERNET,
Manifest.permission.ACCESS_NETWORK_STATE,
Manifest.permission.ACCESS_COARSE_LOCATION,
Manifest.permission.ACCESS_FINE_LOCATION
},
MY_PERMISSIONS_REQUEST_WRITE_FIELS);
}
}else{
go_next();
}
}
@Override
public void onRequestPermissionsResult(int requestCode,
String permissions[], int[] grantResults) {
if(requestCode == MY_PERMISSIONS_REQUEST_WRITE_FIELS) {
if (grantResults.length > 0
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
go_next();
} else {
AlertDialog.Builder builder = new AlertDialog.Builder(Splash.this);
builder.setMessage(R.string.permission_required)
.setPositiveButton(R.string.fire, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// FIRE ZE MISSILES!
openPermissionScreen();
}
})
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// User cancelled the dialog
dialog.dismiss();
}
});
dialog = builder.show();
}
return;
}
}
public void go_next(){
Intent intent = new Intent(Splash.this, MainActivity.class);
startActivity(intent);
finish();
}
public void openPermissionScreen(){
// startActivityForResult(new Intent(android.provider.Settings.ACTION_SETTINGS), 0);
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
Uri.fromParts("package", Splash.this.getPackageName(), null));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
@Override
protected void onDestroy() {
if(dialog!=null){
dialog.dismiss();
dialog = null;
}
super.onDestroy();
}
}