Skip to content

Instantly share code, notes, and snippets.

@thaiall
Created August 2, 2017 14:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thaiall/9551cc6b1f7508663f372f760518b59f to your computer and use it in GitHub Desktop.
Save thaiall/9551cc6b1f7508663f372f760518b59f to your computer and use it in GitHub Desktop.
Android Studio : openweb2 by customtabs
package com.thaiall.www.openweb2;
import android.support.v7.app.AppCompatActivity;
//import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
//import android.support.customtabs.CustomTabsClient;
import android.support.customtabs.CustomTabsIntent;
//import android.support.customtabs.CustomTabsServiceConnection;
//import android.support.customtabs.CustomTabsSession;
import android.support.v4.content.ContextCompat;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Use a CustomTabsIntent.Builder to configure CustomTabsIntent.
String url = "http://www.thaiall.com/actress/missgrand2017";
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
// set toolbar color and/or setting custom actions before invoking build()
// Once ready, call CustomTabsIntent.Builder.build() to create a CustomTabsIntent
CustomTabsIntent customTabsIntent = builder.build();
// and launch the desired Url with CustomTabsIntent.launchUrl()
customTabsIntent.launchUrl(this, Uri.parse(url));
// set toolbar color
builder.setToolbarColor(ContextCompat.getColor(this, R.color.colorAccent));
// add share action to menu list
builder.addDefaultShareMenuItem();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment