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();
}
}

Dani AI

Generated

A few concrete causes jump out from the posted code that typically produce the “stuck on splash” symptom on Android 6+ (Marshmallow). First, the code checks CAMERA but does not include CAMERA in the requestPermissions(...) array — if camera is denied the initial check keeps the flow in the “permissions missing” branch. Second, the shouldShowRequestPermissionRationale(...) logic is inverted: a true result means you should show an explanation and then request again, not call go_next(). Third, onRequestPermissionsResult only tests grantResults[0] even though multiple permissions are requested — you must check every entry. Fourth, you open the app settings with a plain startActivity(...) and only run the permission check in onCreate, so enabling permissions in Settings won’t resume the splash flow. As recommended, use logcat and breakpoints while testing.

A compact, practical fix: centralize the required dangerous permissions, request only the missing ones, iterate grantResults to ensure all were granted, and re-check permissions in onResume (or use startActivityForResult for settings). Example of checking results:

boolean allGranted = true;
for (int r : grantResults) {
  if (r != PackageManager.PERMISSION_GRANTED) { allGranted = false; break; }
}
if (allGranted) go_next(); else showSettingsOrRationale();

Checklist to apply now:

  • Add every dangerous permission you use (e.g., CAMERA, READ/WRITE_EXTERNAL_STORAGE, LOCATION) to both the manifest and the runtime request list.
  • Do not request normal permissions like INTERNET at runtime.
  • Move permission checks into onResume() or re-check in onActivityResult() after returning from settings.
  • Handle “Never ask again” by detecting !shouldShowRequestPermissionRationale(...) and guiding the user to app settings.
  • Use logcat to spot exceptions in MainActivity or NPEs that could return control to the splash.

For the official Android runtime-permissions pattern see the developer guide: Request app permissions.

Recommended Answers

All 3 Replies

Is there any other way because it the current issue was only showing in android 6 and latest versions.

I used that method in Android 4.x and 5.x so I have to ask you to reveal more. Such as are you setup to debug an app and if you write apps?
Maybe the answer here is if you don't actually do this work is to find another developer to get in there.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.