当前位置: 首页>>代码示例>>Java>>正文


Java CustomTabsHelper.getPackageNameToUse方法代码示例

本文整理汇总了Java中org.chromium.customtabsclient.shared.CustomTabsHelper.getPackageNameToUse方法的典型用法代码示例。如果您正苦于以下问题:Java CustomTabsHelper.getPackageNameToUse方法的具体用法?Java CustomTabsHelper.getPackageNameToUse怎么用?Java CustomTabsHelper.getPackageNameToUse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.chromium.customtabsclient.shared.CustomTabsHelper的用法示例。


在下文中一共展示了CustomTabsHelper.getPackageNameToUse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: openCustomTab

import org.chromium.customtabsclient.shared.CustomTabsHelper; //导入方法依赖的package包/类
/**
 * 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
    if (packageName == null) {
        if (fallback != null) {
            fallback.openUri(activity, uri);
        }
    } else {
        customTabsIntent.intent.setPackage(packageName);
        customTabsIntent.launchUrl(activity, uri);
    }
}
 
开发者ID:why168,项目名称:AndroidProjects,代码行数:26,代码来源:CustomTabActivityHelper.java

示例2: openCustomTab

import org.chromium.customtabsclient.shared.CustomTabsHelper; //导入方法依赖的package包/类
/**
 * 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
    if (packageName == null) {
        if (fallback != null) {
            fallback.openUri(activity, uri);
        }
    } else {
        customTabsIntent.intent.setPackage(packageName);
        customTabsIntent.launchUrl(activity, uri);
    }
}
 
开发者ID:Androideity,项目名称:AndroidStudioTutorials,代码行数:26,代码来源:CustomTabActivityHelper.java

示例3: launchCustomTabsWithSlide

import org.chromium.customtabsclient.shared.CustomTabsHelper; //导入方法依赖的package包/类
private void launchCustomTabsWithSlide(String url) {
    String packageName = CustomTabsHelper.getPackageNameToUse(this);
    if (TextUtils.isEmpty(packageName)) {
        startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
        return;
    }

    CustomTabsIntent.Builder builder =
            new CustomTabsIntent.Builder()
                    .setToolbarColor(ContextCompat.getColor(this, R.color.colorPrimary))
                    .setStartAnimations(this, R.anim.customtabs_in_slide_anim, R.anim.application_out_slide_anim)
                    .setExitAnimations(this, R.anim.application_in_slide_anim, R.anim.customtabs_out_slide_anim)
            ;

    CustomTabsIntent customTabsIntent = builder.build();
    customTabsIntent.intent.setPackage(packageName);
    customTabsIntent.launchUrl(this, Uri.parse(url));
}
 
开发者ID:sakebook,项目名称:CustomTabsSample,代码行数:19,代码来源:CustomAnimationActivity.java

示例4: launchCustomTabsWithModal

import org.chromium.customtabsclient.shared.CustomTabsHelper; //导入方法依赖的package包/类
private void launchCustomTabsWithModal(String url) {
    String packageName = CustomTabsHelper.getPackageNameToUse(this);
    if (TextUtils.isEmpty(packageName)) {
        startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
        return;
    }

    CustomTabsIntent.Builder builder =
            new CustomTabsIntent.Builder()
                    .setToolbarColor(ContextCompat.getColor(this, R.color.colorPrimary))
                    .setStartAnimations(this, R.anim.customtabs_in_modal_anim, R.anim.application_out_modal_anim)
                    .setExitAnimations(this, R.anim.application_in_modal_anim, R.anim.customtabs_out_modal_anim)
            ;

    CustomTabsIntent customTabsIntent = builder.build();
    customTabsIntent.intent.setPackage(packageName);
    customTabsIntent.launchUrl(this, Uri.parse(url));
}
 
开发者ID:sakebook,项目名称:CustomTabsSample,代码行数:19,代码来源:CustomAnimationActivity.java

示例5: launchCustomTabs

import org.chromium.customtabsclient.shared.CustomTabsHelper; //导入方法依赖的package包/类
private void launchCustomTabs(String url) {
    String packageName = CustomTabsHelper.getPackageNameToUse(this);
    if (TextUtils.isEmpty(packageName)) {
        startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
        return;
    }

    CustomTabsIntent.Builder builder =
            new CustomTabsIntent.Builder()
                    .setActionButton(BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher), "sample1", createActivityPendingIntent(11)) // Not displayed.
                    .setActionButton(ResourceUtil.createBitmap(this, R.drawable.ic_android_pink_500), "sample2", createActivityPendingIntent(12))
            ;

    CustomTabsIntent customTabsIntent = builder.build();
    customTabsIntent.intent.setPackage(packageName);
    customTabsIntent.launchUrl(this, Uri.parse(url));
}
 
开发者ID:sakebook,项目名称:CustomTabsSample,代码行数:18,代码来源:CustomToolbarActivity.java

示例6: launchCustomTabsWithMenuItem

import org.chromium.customtabsclient.shared.CustomTabsHelper; //导入方法依赖的package包/类
private void launchCustomTabsWithMenuItem(String url) {
    String packageName = CustomTabsHelper.getPackageNameToUse(this);
    if (TextUtils.isEmpty(packageName)) {
        startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
        return;
    }

    CustomTabsIntent.Builder builder =
            new CustomTabsIntent.Builder()
                    .addMenuItem("copy1", createServicePendingIntent(21))
                    .addMenuItem("copy2", createServicePendingIntent(22))
                    .addMenuItem("share1", createBroadcastPendingIntent(23))
                    .addMenuItem("share2", createBroadcastPendingIntent(24))
                    .addMenuItem("home1", createActivityPendingIntent(25))
                    .addMenuItem("home2", createActivityPendingIntent(26)) // Not displayed.
                    .addDefaultShareMenuItem()
                    .setCloseButtonIcon(ResourceUtil.createBitmap(this, R.drawable.ic_android_pink_500))
            ;

    CustomTabsIntent customTabsIntent = builder.build();
    customTabsIntent.intent.setPackage(packageName);
    customTabsIntent.launchUrl(this, Uri.parse(url));
}
 
开发者ID:sakebook,项目名称:CustomTabsSample,代码行数:24,代码来源:CustomToolbarActivity.java

示例7: launchCustomTabsWithBottomBar

import org.chromium.customtabsclient.shared.CustomTabsHelper; //导入方法依赖的package包/类
private void launchCustomTabsWithBottomBar(String url) {
    String packageName = CustomTabsHelper.getPackageNameToUse(this);
    if (TextUtils.isEmpty(packageName)) {
        startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
        return;
    }

    Intent broadcastIntent = new Intent(this, BottombarBroadcastReceiver.class);
    PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 110, broadcastIntent, PendingIntent.FLAG_UPDATE_CURRENT);
    int[] ids = {R.id.twitter, R.id.line, R.id.facebook};

    CustomTabsIntent customTabsIntent = new CustomTabsIntent.Builder()
            .setSecondaryToolbarViews(createBottomBarRemoteView(), ids, pendingIntent)
            .build();

    customTabsIntent.intent.setPackage(packageName);
    customTabsIntent.launchUrl(this, Uri.parse(url));
}
 
开发者ID:sakebook,项目名称:CustomTabsSample,代码行数:19,代码来源:RemoteViewActivity.java

示例8: launchCustomTabsWithTransparent

import org.chromium.customtabsclient.shared.CustomTabsHelper; //导入方法依赖的package包/类
private void launchCustomTabsWithTransparent(String url) {
    String packageName = CustomTabsHelper.getPackageNameToUse(this);
    if (TextUtils.isEmpty(packageName)) {
        startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
        return;
    }

    // This is a dummy
    int[] ids = {0};

    CustomTabsIntent customTabsIntent = new CustomTabsIntent.Builder()
            .setSecondaryToolbarViews(createTransparentRemoteView(), ids, null)
            .build();

    customTabsIntent.intent.setPackage(packageName);
    customTabsIntent.launchUrl(this, Uri.parse(url));
}
 
开发者ID:sakebook,项目名称:CustomTabsSample,代码行数:18,代码来源:RemoteViewActivity.java

示例9: launchCustomTabs

import org.chromium.customtabsclient.shared.CustomTabsHelper; //导入方法依赖的package包/类
private void launchCustomTabs(String url) {
    String packageName = CustomTabsHelper.getPackageNameToUse(this);
    if (TextUtils.isEmpty(packageName)) {
        startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
        return;
    }
    Intent snsIntent = new Intent(this, SessionBroadcastReceiver.class);
    PendingIntent snsPendingIntent = PendingIntent.getBroadcast(this, 121, snsIntent, PendingIntent.FLAG_UPDATE_CURRENT);

    CustomTabsIntent customTabsIntent = new CustomTabsIntent.Builder(session)
            .setToolbarColor(ContextCompat.getColor(this, R.color.colorPrimary))
            .setActionButton(ResourceUtil.createBitmap(SessionActivity.this, icons[0]), "SNS", snsPendingIntent)
            .addMenuItem("toggle", createRemoteViewPendingIntent(this))
            .setSecondaryToolbarViews(SessionBroadcastReceiver.createRemoteView(), ids, null)
            .build();
    customTabsIntent.intent.setPackage(packageName);
    CustomTabsHelper.addKeepAliveExtra(this, customTabsIntent.intent);
    customTabsIntent.launchUrl(this, Uri.parse(url));
}
 
开发者ID:sakebook,项目名称:CustomTabsSample,代码行数:20,代码来源:SessionActivity.java

示例10: openCustomTab

import org.chromium.customtabsclient.shared.CustomTabsHelper; //导入方法依赖的package包/类
/**
 * 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
    if (packageName == null) {
        if (fallback != null) {
            fallback.openUri(activity, uri);
        }
    } else {
        customTabsIntent.intent.setPackage(packageName);
        customTabsIntent.launchUrl(activity, uri);
    }
}
 
开发者ID:GoogleChrome,项目名称:custom-tabs-client,代码行数:26,代码来源:CustomTabActivityHelper.java

示例11: show

import org.chromium.customtabsclient.shared.CustomTabsHelper; //导入方法依赖的package包/类
private void show(String url, @ColorInt int toolbarColor, boolean showDefaultShareMenuItem, String transition) {
    CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder(getSession())
            .setToolbarColor(toolbarColor);
    if(showDefaultShareMenuItem)
        builder.addDefaultShareMenuItem();
    if(!TextUtils.isEmpty(transition))
        addTransition(builder, transition);
   

    CustomTabsIntent customTabsIntent = builder.build();
    
    String packageName = CustomTabsHelper.getPackageNameToUse(cordova.getActivity());
    if ( packageName != null ) {
       customTabsIntent.intent.setPackage(packageName);
    }

    startCustomTabActivity(url, customTabsIntent.intent);
}
 
开发者ID:EddyVerbruggen,项目名称:cordova-plugin-safariviewcontroller,代码行数:19,代码来源:ChromeCustomTabPlugin.java

示例12: connect

import org.chromium.customtabsclient.shared.CustomTabsHelper; //导入方法依赖的package包/类
private void connect() {
    if (customTabsClient != null) {
        // already connected
        return;
    }
    String packageName = CustomTabsHelper.getPackageNameToUse(this);
    if (TextUtils.isEmpty(packageName)) {
        return;
    }
    connection = new ServiceConnection(this);
    CustomTabsClient.bindCustomTabsService(this, packageName, connection);
}
 
开发者ID:sakebook,项目名称:CustomTabsSample,代码行数:13,代码来源:PrefetchActivity.java

示例13: launchCustomTabsWithReferrer

import org.chromium.customtabsclient.shared.CustomTabsHelper; //导入方法依赖的package包/类
private void launchCustomTabsWithReferrer(Context context, String url) {
    String packageName = CustomTabsHelper.getPackageNameToUse(this);
    if (TextUtils.isEmpty(packageName)) {
        startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
        return;
    }
    CustomTabsIntent customTabsIntent = new CustomTabsIntent.Builder().build();
    customTabsIntent.intent.setPackage(packageName);

    customTabsIntent.intent.putExtra(Intent.EXTRA_REFERRER,
            Uri.parse("android-app://" + context.getPackageName()));
    customTabsIntent.launchUrl(context, Uri.parse(url));
}
 
开发者ID:sakebook,项目名称:CustomTabsSample,代码行数:14,代码来源:CustomRequestActivity.java

示例14: launchCustomTabs

import org.chromium.customtabsclient.shared.CustomTabsHelper; //导入方法依赖的package包/类
private void launchCustomTabs(String url) {
    String packageName = CustomTabsHelper.getPackageNameToUse(this);
    if (TextUtils.isEmpty(packageName)) {
        startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
        return;
    }
    CustomTabsIntent customTabsIntent = new CustomTabsIntent.Builder()
            .build();
    customTabsIntent.intent.setPackage(packageName);
    customTabsIntent.launchUrl(this, Uri.parse(url));
}
 
开发者ID:sakebook,项目名称:CustomTabsSample,代码行数:12,代码来源:WarmupActivity.java

示例15: launchCustomTabs

import org.chromium.customtabsclient.shared.CustomTabsHelper; //导入方法依赖的package包/类
private void launchCustomTabs(String url) {
    String packageName = CustomTabsHelper.getPackageNameToUse(this);
    if (TextUtils.isEmpty(packageName)) {
        startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
        return;
    }
    CustomTabsIntent customTabsIntent = new CustomTabsIntent.Builder().build();
    customTabsIntent.intent.setPackage(packageName);
    customTabsIntent.launchUrl(this, Uri.parse(url));
}
 
开发者ID:sakebook,项目名称:CustomTabsSample,代码行数:11,代码来源:PrefetchActivity.java


注:本文中的org.chromium.customtabsclient.shared.CustomTabsHelper.getPackageNameToUse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。