Java Code Examples for android.support.customtabs.CustomTabsIntent#launchUrl()
The following examples show how to use
android.support.customtabs.CustomTabsIntent#launchUrl() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProductPresenterImpl.java From Jager with GNU General Public License v3.0 | 6 votes |
@Override public void onImageClick (View v, int feedItem) { Product product = mPosts.getPosts ().get (feedItem); Context context = mProductView.getContext (); if (AppSettings.getOpenInBrowserPref (context)) { Intent intent = new Intent (Intent.ACTION_VIEW).setData (Uri .parse (product.getProductUrl ())); context.startActivity (intent); } else { CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder (); builder.setToolbarColor (ContextCompat.getColor ( mProductView.getContext (), R.color.primary_color)); builder.addDefaultShareMenuItem (); CustomTabsIntent customTabsIntent = builder.build (); customTabsIntent.launchUrl (mProductView.getContext (), Uri.parse (product .getProductUrl ())); } }
Example 2
Source File: DropboxConfig.java From rcloneExplorer with MIT License | 6 votes |
@Override protected Boolean doInBackground(Void... voids) { process = rclone.configCreate(options); String url = "http://127.0.0.1:53682/auth"; CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder(); CustomTabsIntent customTabsIntent = builder.build(); customTabsIntent.launchUrl(context, Uri.parse(url)); try { process.waitFor(); } catch (InterruptedException e) { e.printStackTrace(); } return process.exitValue() == 0; }
Example 3
Source File: PcloudConfig.java From rcloneExplorer with MIT License | 6 votes |
@Override protected Boolean doInBackground(Void... voids) { process = rclone.configCreate(options); String url = "http://127.0.0.1:53682/auth"; CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder(); CustomTabsIntent customTabsIntent = builder.build(); customTabsIntent.launchUrl(context, Uri.parse(url)); try { process.waitFor(); } catch (InterruptedException e) { e.printStackTrace(); } return process.exitValue() == 0; }
Example 4
Source File: YandexConfig.java From rcloneExplorer with MIT License | 6 votes |
@Override protected Boolean doInBackground(Void... voids) { process = rclone.configCreate(options); String url = "http://127.0.0.1:53682/auth"; CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder(); CustomTabsIntent customTabsIntent = builder.build(); customTabsIntent.launchUrl(context, Uri.parse(url)); try { process.waitFor(); } catch (InterruptedException e) { e.printStackTrace(); } return process.exitValue() == 0; }
Example 5
Source File: DriveConfig.java From rcloneExplorer with MIT License | 6 votes |
@Override protected Boolean doInBackground(Void... voids) { process = rclone.configCreate(options); String url = "http://127.0.0.1:53682/auth"; CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder(); CustomTabsIntent customTabsIntent = builder.build(); customTabsIntent.launchUrl(context, Uri.parse(url)); try { process.waitFor(); } catch (InterruptedException e) { e.printStackTrace(); } return process.exitValue() == 0; }
Example 6
Source File: HubicConfig.java From rcloneExplorer with MIT License | 6 votes |
@Override protected Boolean doInBackground(Void... voids) { process = rclone.configCreate(options); String url = "http://127.0.0.1:53682/auth"; CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder(); CustomTabsIntent customTabsIntent = builder.build(); customTabsIntent.launchUrl(context, Uri.parse(url)); try { process.waitFor(); } catch (InterruptedException e) { e.printStackTrace(); } return process.exitValue() == 0; }
Example 7
Source File: CustomTabAuthHandler.java From blade-player with GNU General Public License v3.0 | 6 votes |
@Override public boolean start(final Activity contextActivity, final AuthenticationRequest request) { final String packageName = getChromePackageName(contextActivity); if (packageName == null) { return false; } if (!hasCustomTabRedirectActivity(contextActivity, request.getRedirectUri())) { return false; } CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder(); builder.setToolbarColor(SPOTIFY_GREEN); final CustomTabsIntent customTabsIntent = builder.build(); customTabsIntent.intent.setPackage(packageName); customTabsIntent.launchUrl(contextActivity, request.toUri()); return true; }
Example 8
Source File: MainActivity.java From homeassist with Apache License 2.0 | 6 votes |
private void showWebUI() { CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder(); //builder.setStartAnimations(mActivity, R.anim.right_in, R.anim.left_out); builder.setStartAnimations(this, R.anim.activity_open_translate, R.anim.activity_close_scale); builder.setExitAnimations(this, R.anim.activity_open_scale, R.anim.activity_close_translate); builder.setToolbarColor(ResourcesCompat.getColor(getResources(), R.color.md_blue_500, null)); // builder.setSecondaryToolbarColor(ResourcesCompat.getColor(getResources(), R.color.md_white_1000, null)); CustomTabsIntent customTabsIntent = builder.build(); try { customTabsIntent.launchUrl(this, mCurrentServer.getBaseUri()); } catch (ActivityNotFoundException e) { showToast(getString(R.string.exception_no_chrome)); } }
Example 9
Source File: ActivityHelper.java From mvvm-template with GNU General Public License v3.0 | 6 votes |
public static void startCustomTab(@NonNull Activity context, @NonNull Uri url) { String packageNameToUse = CustomTabsHelper.getPackageNameToUse(context); if (packageNameToUse != null) { CustomTabsIntent customTabsIntent = new CustomTabsIntent.Builder() .setToolbarColor(ViewHelper.getPrimaryColor(context)) .setShowTitle(true) .build(); customTabsIntent.intent.setPackage(packageNameToUse); try { customTabsIntent.launchUrl(context, url); } catch (ActivityNotFoundException ignored) { openChooser(context, url, true); } } else { openChooser(context, url, true); } }
Example 10
Source File: ChromeTabActivity.java From More-For-GO with GNU General Public License v3.0 | 5 votes |
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.chrome_tabs); if (Globals.url != null) { CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder(); CustomTabsIntent customTabsIntent = builder.build(); customTabsIntent.launchUrl(ChromeTabActivity.this, Uri.parse(Globals.url)); } else { startActivity(getPackageManager().getLaunchIntentForPackage(Constants.GOPackageName)); finish(); } }
Example 11
Source File: SearchClinics.java From Crimson with Apache License 2.0 | 5 votes |
private void openCustomTab(String title) { CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder(); builder.setToolbarColor(ContextCompat.getColor(this, R.color.colorPrimary)); builder.addDefaultShareMenuItem(); CustomTabsIntent customTabsIntent = builder.build(); customTabsIntent.launchUrl(this, Uri.parse("http://www.google.com/search?q=" + title)); }
Example 12
Source File: AppUtil.java From droidkaigi2016 with Apache License 2.0 | 5 votes |
public static void showWebPage(Activity activity, @NonNull String url) { CustomTabsIntent intent = new CustomTabsIntent.Builder() .setShowTitle(true) .setToolbarColor(ContextCompat.getColor(activity, R.color.theme500)) .build(); intent.launchUrl(activity, Uri.parse(url)); }
Example 13
Source File: PreferencesFragment.java From HouSi with Apache License 2.0 | 5 votes |
private void showFaqTab() { String faqUrl = BuildConfig.FAQ_URL; CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder(); builder.setToolbarColor(getResources().getColor(R.color.colorAccent)) .setShowTitle(true) .addDefaultShareMenuItem(); CustomTabsIntent intent = builder.build(); intent.launchUrl(getContext(), Uri.parse(faqUrl)); }
Example 14
Source File: PortfolioActivity.java From EasyPortfolio with Apache License 2.0 | 5 votes |
private void openLink(String link) { CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder(); builder.setToolbarColor(ContextCompat.getColor(this, R.color.cardview_dark_background)); CustomTabsIntent customTabsIntent = builder.build(); customTabsIntent.launchUrl(this, Uri.parse(link)); }
Example 15
Source File: BaseAdsActivity.java From twoh-android-material-design with MIT License | 5 votes |
protected void readTheTutorial(String url){ CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder(); CustomTabsIntent customTabsIntent = builder.build(); customTabsIntent.intent.putExtra(Intent.EXTRA_REFERRER, Uri.parse(Intent.URI_ANDROID_APP_SCHEME + "//" + this.getPackageName())); customTabsIntent.launchUrl(this, Uri.parse(url)); }
Example 16
Source File: Intents.java From droidconat-2016 with Apache License 2.0 | 5 votes |
public static void startExternalUrl(@NonNull Activity activity, @NonNull String url) { CustomTabsIntent intent = new CustomTabsIntent.Builder() .setShowTitle(true) .setToolbarColor(ContextCompat.getColor(activity, R.color.primary)) .build(); intent.launchUrl(activity, Uri.parse(url)); }
Example 17
Source File: CustomTabActivityHelper.java From Focus with GNU General Public License v3.0 | 5 votes |
/** * Opens the URL on a Custom Tab if possible. Otherwise fallsback to opening it on a WebView. * * @param activity The host activity. * @param customTabsIntent a CustomTabsIntent to be used if Custom Tabs is available. * @param uri the Uri to be opened. * @param fallback a CustomTabFallback to be used if Custom Tabs is not available. */ public static void openCustomTab(Activity activity, CustomTabsIntent customTabsIntent, Uri uri, CustomTabFallback fallback) { String packageName = CustomTabsHelper.getPackageNameToUse(activity); //If we cant find a package name, it means theres no browser that supports //Chrome Custom Tabs installed. So, we fallback to the webview //如果使用了不使用Chrome内核,则直接打开 if(UserPreference.queryValueByKey(UserPreference.notUseChrome,"0").equals("1")){ if (fallback != null) { fallback.openUri(activity, uri); } }else { if (packageName == null) {//普通打开 if (fallback != null) { fallback.openUri(activity, uri); } } else { customTabsIntent.intent.setPackage(packageName); try { customTabsIntent.launchUrl(activity, uri); }catch (ActivityNotFoundException e){ ALog.d("为什么活动没了?" + e); //普通方法 if (fallback != null) { fallback.openUri(activity, uri); } } } } }
Example 18
Source File: StackOverflowUserAdapter.java From Learning-Resources with MIT License | 5 votes |
public void loadCustomTabs(String url) { CustomTabsIntent.Builder mBuilder = new CustomTabsIntent.Builder(getSession()); mBuilder.setToolbarColor(ContextCompat.getColor(mContext, R.color.colorPrimary)); mBuilder.setCloseButtonIcon(BitmapFactory.decodeResource(mContext.getResources(), R.mipmap.ic_arrow_back_white_24dp)); mBuilder.addMenuItem("Share", setMenuItem(url)); mBuilder.setActionButton(BitmapFactory.decodeResource(mContext.getResources(), R.mipmap.ic_file_download_white_24dp), "Engineering @Lets Nurture", addActionButton()); mBuilder.setStartAnimations(mContext, R.anim.slide_in_right, R.anim.slide_out_left); mBuilder.setExitAnimations(mContext, R.anim.slide_in_left, R.anim.slide_out_right); CustomTabsIntent mIntent = mBuilder.build(); mIntent.launchUrl((Activity) mContext, Uri.parse(url)); }
Example 19
Source File: AppOpener.java From OpenHub with GNU General Public License v3.0 | 4 votes |
public static void openInCustomTabsOrBrowser(@NonNull Context context, @NonNull String url){ if(StringUtils.isBlank(url)){ Toasty.warning(context, context.getString(R.string.invalid_url), Toast.LENGTH_LONG).show(); return; } //check http prefix if(!url.contains("//")){ url = "http://".concat(url); } String customTabsPackageName ; if (PrefUtils.isCustomTabsEnable() && (customTabsPackageName = CustomTabsHelper.INSTANCE.getBestPackageName(context) ) != null) { Bitmap backIconBitmap = ViewUtils.getBitmapFromResource(context, R.drawable.ic_arrow_back_title); Intent shareIntent = new Intent(context.getApplicationContext(), ShareBroadcastReceiver.class); shareIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); PendingIntent sharePendingIntent = PendingIntent.getBroadcast( context.getApplicationContext(), 0, shareIntent, 0); Intent copyIntent = new Intent(context.getApplicationContext(), CopyBroadcastReceiver.class); copyIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); PendingIntent copyPendingIntent = PendingIntent.getBroadcast( context.getApplicationContext(), 0, copyIntent, 0); CustomTabsIntent customTabsIntent = new CustomTabsIntent.Builder() .setToolbarColor(ViewUtils.getPrimaryColor(context)) .setCloseButtonIcon(backIconBitmap) .setShowTitle(true) .addMenuItem(context.getString(R.string.share), sharePendingIntent) .addMenuItem(context.getString(R.string.copy_url), copyPendingIntent) // .setStartAnimations(context, R.anim.slide_in_right, R.anim.slide_out_left) // .setExitAnimations(context, android.R.anim.slide_in_left, android.R.anim.slide_out_right) .build(); customTabsIntent.intent.setPackage(customTabsPackageName); customTabsIntent.launchUrl(context, Uri.parse(url)); if(PrefUtils.isCustomTabsTipsEnable()){ Toasty.info(context, context.getString(R.string.use_custom_tabs_tips), Toast.LENGTH_LONG).show(); PrefUtils.set(PrefUtils.CUSTOM_TABS_TIPS_ENABLE, false); } } else { openInBrowser(context,url); } }
Example 20
Source File: BrowserActionActivity.java From custom-tabs-client with Apache License 2.0 | 4 votes |
protected void openCustomTabsLink(final Uri url) { final CustomTabsIntent intent = new CustomTabsIntent.Builder(mCustomTabActivityHelper.getSession()).build(); intent.launchUrl(BrowserActionActivity.this, url); }