问题
I want to set Webview as fallback of chrome custom tab. If user don't have chrome installed on their mobile I want Webview to open url in the app.
public class Main3Activity extends AppCompatActivity {
static final String SITE_URL = "http://secure.shopershop.in/amazon-mobile-accessories";
static final String SITE_URL1 = "http://secure.shopershop.in/flipkart-mobile-accessories";
CustomTabsIntent customTabsIntent;
CustomTabsIntent.Builder intentBuilder;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main3);
AdView mAdView = (AdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
setTitle("Mobile Accessories");
intentBuilder = new CustomTabsIntent.Builder();
intentBuilder.setToolbarColor(ContextCompat.getColor(this, R.color.colorPrimary));
intentBuilder.setExitAnimations(this, R.anim.right_to_left_end, R.anim.left_to_right_end);
intentBuilder.setStartAnimations(this, R.anim.left_to_right_start, R.anim.right_to_left_start);
intentBuilder.setSecondaryToolbarColor(ContextCompat.getColor(this, R.color.colorPrimary));
customTabsIntent = intentBuilder.build();
intentBuilder.addDefaultShareMenuItem();
intentBuilder.setCloseButtonIcon(BitmapFactory.decodeResource(
getResources(), R.drawable.ic_arrow_back_black_24dp));
}
public void performAction(View arg0) {
customTabsIntent.launchUrl(this, Uri.parse(SITE_URL));
}
public void performAction1 (View arg0) {
customTabsIntent.launchUrl(this, Uri.parse(SITE_URL1));
}
}
来源:https://stackoverflow.com/questions/45720315/how-to-set-fallback-of-chrome-custom-tab-to-webview