Skip to content

Instantly share code, notes, and snippets.

@vinitraj10
Last active January 24, 2020 12:25
Show Gist options
  • Select an option

  • Save vinitraj10/916b1a2039d6cb3494bf7ba1909d7977 to your computer and use it in GitHub Desktop.

Select an option

Save vinitraj10/916b1a2039d6cb3494bf7ba1909d7977 to your computer and use it in GitHub Desktop.
import android.content.Intent;
import android.os.Handler;
import androidx.appcompat.app.AppCompatActivity;
import com.google.androidbrowserhelper.trusted.LauncherActivity;
public class CustomActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
// checking if a valid chrome installed in user's
// device or not using a custom made function which
//
boolean _isValidChrome = isValidChrome(getApplicationContext());
if (_isValidChrome) {
Intent LauncherIntent = new Intent(SplashActivity.this, LauncherActivity.class);
// if chrome version is greater than 75
// then custom splash screen can be used
if (chromeVersion >= 75) {
startActivity(LauncherIntent);
finish();
} else {
// to handle custom splash screen
// adding a custom delay,of 500 ms
// to launch the
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
startActivity(LauncherIntent);
finish();
}
}, 500);
}
} else {
// to handle the case where user
// don't have chrome which has TWA support
// starting a new chromeactivity which you can
// create of your own and,design on your own
// First create a activity and design it,using its
// layout file.
Intent chromeActivity = new Intent(this, ChromeUpdate.class);
startActivity(chromeActivity);
finish();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment