android Studio

public class ActivityName extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // remove title
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.main);
    }
}


// then you need to add new theme
<style name="Theme.AppCompat.Light.NoActionBar.FullScreen" parent="@style/Theme.AppCompat.Light.NoActionBar">
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowActionBar">false</item>
    <item name="android:windowFullscreen">true</item>
    <item name="android:windowContentOverlay">@null</item>
</style>


//and then use it AndroidManifest.xml file:
<activity android:name=".ActivityName"
    android:label="@string/app_name"
    android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen"/>
//after creating java class and .xml file for splash screen 
//add this code in onCreat method

        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
            //start new activity after splash screen
                Intent i = new Intent(splash.this, MainActivity.class);
                startActivity(i);
                finish();
            }
        },SPLASH_DISPLAY_LENGTH);
        
//add this to manifest
<activity android:name=".splash"
            android:theme="@style/Theme.AppCompat.NoActionBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
@Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {

        switch (requestCode){
            case MY_PERMISSIONS_REQUEST_READ_CONTACTS: {
                //if request is cancelled, the result arrays are empty.
                if (grantResults.length > 0
                    && grantResults[0] == PackageManager.PERMISSION_GRANTED){
                    //permission was granted, yay! Do the
                    //contacts-related task you need to do.
                    Log.d("TAG", "response granted");
                }
                else {
                    //permission denied, boo! Disable the
                    // functionality that depends on this permission.
                    Log.d("TAG", "response not granted");

                }
                return;
            }
            //other 'case' lines to check for other
            //permissions this app might request
        }
    }
    
    private void requestPermission(){
        if (ContextCompat.checkSelfPermission(MainActivity.this,
                Manifest.permission.READ_SMS)
                != PackageManager.PERMISSION_GRANTED) {

            if (ActivityCompat.shouldShowRequestPermissionRationale(MainActivity.this,
                    Manifest.permission.READ_SMS)){

                Log.d("TAG","should show rationale");
            }
            else {
                ActivityCompat.requestPermissions(MainActivity.this,
                        new String[]{Manifest.permission.READ_SMS}, MY_PERMISSIONS_REQUEST_READ_CONTACTS);
                Log.d("TAG","else");
            }
        }
    }

Similiar Collections