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


Java CustomTabsIntent.Builder方法代码示例

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


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

示例1: onExternalPageRequest

import android.support.customtabs.CustomTabsIntent; //导入方法依赖的package包/类
@Override
public void onExternalPageRequest(String url) {

    CustomTabsIntent.Builder intentBuilder = new CustomTabsIntent.Builder();
    intentBuilder.setShowTitle(true);
    intentBuilder.setToolbarColor(ContextCompat.getColor(fActivity, R.color.colorPrimary));

    Intent actionIntent = new Intent(Intent.ACTION_SEND);
    actionIntent.setType("text/plain");
    actionIntent.putExtra(Intent.EXTRA_TEXT, url);

    PendingIntent menuItemPendingIntent = PendingIntent.getActivity(fActivity, 0, actionIntent, 0);
    intentBuilder.setActionButton(BitmapFactory.decodeResource(getResources(), R.drawable.ic_share), (fActivity.getString(R.string.update_share)), menuItemPendingIntent);
    intentBuilder.addMenuItem(fActivity.getString(R.string.update_share), menuItemPendingIntent);

    intentBuilder.build().launchUrl(fActivity, Uri.parse(url));
}
 
开发者ID:sfilmak,项目名称:MakiLite,代码行数:18,代码来源:MakiListener.java

示例2: startUserAuth

import android.support.customtabs.CustomTabsIntent; //导入方法依赖的package包/类
private void startUserAuth() {
    Log.i(TAG, "Starting user auth");

    loginListener.onEvent(AuthRepo.this, AUTH_USER_AUTH_START);

    // may need to do this off UI thread?

    AuthorizationRequest.Builder authRequestBuilder = new AuthorizationRequest.Builder(
            authState.getAuthorizationServiceConfiguration(),
            clientId,
            ResponseTypeValues.CODE,
            Uri.parse(redirectUri))
            .setScope(authScope);
    AuthorizationRequest authRequest = authRequestBuilder.build();

    CustomTabsIntent.Builder intentBuilder =
            authService.createCustomTabsIntentBuilder(authRequest.toUri());
    intentBuilder.setToolbarColor(app.getColorValue(R.color.colorAccent));
    CustomTabsIntent authIntent = intentBuilder.build();

    Intent intent = authService.getAuthorizationRequestIntent(authRequest, authIntent);

    loginListener.onUserAgentRequest(AuthRepo.this, intent);
}
 
开发者ID:approov,项目名称:AppAuth-OAuth2-Books-Demo,代码行数:25,代码来源:AuthRepo.java

示例3: onOptionsItemSelected

import android.support.customtabs.CustomTabsIntent; //导入方法依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    switch (id) {
        case android.R.id.home:
            startActivity(new Intent(getActivity(), SettingsActivity.class));
            return true;
        case R.id.action_send_feedback:
            CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
            builder.setToolbarColor(getResources().getColor(R.color.colorPrimary));
            builder.addDefaultShareMenuItem();
            final CustomTabsIntent customTabsIntent = builder.build();
            customTabsIntent.launchUrl(getContext(), Uri.parse(sendFeedbackUrl));
            return true;
        case R.id.action_help:
            // TODO: Add some stuff
            return true;
    }
    return super.onOptionsItemSelected(item);
}
 
开发者ID:Chan4077,项目名称:StudyBuddy,代码行数:21,代码来源:SettingsActivity.java

示例4: launchCustomTabs

import android.support.customtabs.CustomTabsIntent; //导入方法依赖的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

示例5: openGplus

import android.support.customtabs.CustomTabsIntent; //导入方法依赖的package包/类
public void openGplus(View view) {

        String url = getString(R.string.ramzplus);
        String url2 = getString(R.string.sajjuplus);

        switch (view.getId()){

            case R.id.gplus:
                CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
                builder.setToolbarColor(ContextCompat.getColor(this, R.color.colorAccent));
                CustomTabsIntent customTabsIntent = builder.build();
                customTabsIntent.launchUrl(this, Uri.parse(url));
                break;
            case R.id.gplus2:
                CustomTabsIntent.Builder builder1 = new CustomTabsIntent.Builder();
                builder1.setToolbarColor(ContextCompat.getColor(this, R.color.black));
                CustomTabsIntent customTabsIntent1 = builder1.build();
                customTabsIntent1.launchUrl(this, Uri.parse(url2));
                break;
        }


    }
 
开发者ID:salRoid,项目名称:Filmy,代码行数:24,代码来源:AboutActivity.java

示例6: getCustomTabIntent

import android.support.customtabs.CustomTabsIntent; //导入方法依赖的package包/类
public static CustomTabsIntent.Builder getCustomTabIntent(@NonNull Context context,
                                                          @NonNull Story story,
                                                          @Nullable CustomTabsSession session) {
    Intent upvoteStory = new Intent(context, UpvoteStoryService.class);
    upvoteStory.setAction(UpvoteStoryService.ACTION_UPVOTE);
    upvoteStory.putExtra(UpvoteStoryService.EXTRA_STORY_ID, story.id);
    PendingIntent pendingIntent = PendingIntent.getService(context, 0, upvoteStory, 0);
    return new CustomTabsIntent.Builder(session)
            .setToolbarColor(ContextCompat.getColor(context, R.color.designer_news))
            .setActionButton(ImageUtils.vectorToBitmap(context,
                            R.drawable.ic_upvote_filled_24dp_white),
                    context.getString(R.string.upvote_story),
                    pendingIntent,
                    false)
            .setShowTitle(true)
            .enableUrlBarHiding()
            .addDefaultShareMenuItem();
}
 
开发者ID:yongjhih,项目名称:android-proguards,代码行数:19,代码来源:DesignerNewsStory.java

示例7: menuTest

import android.support.customtabs.CustomTabsIntent; //导入方法依赖的package包/类
@Test
public void menuTest() throws Exception {
    final CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
    final PendingIntent pendingIntent = PendingIntent.getActivity(null, 0, null, 0);

    builder.addMenuItem("menuitem1", pendingIntent);
    builder.addMenuItem("menuitem2", pendingIntent);
    // We can only handle menu items with an actual PendingIntent, other ones should be ignored:
    builder.addMenuItem("menuitemIGNORED", null);

    final CustomTabsIntent customTabsIntent = builder.build();

    final CustomTabConfig config = CustomTabConfig.parseCustomTabIntent(RuntimeEnvironment.application, new SafeIntent(customTabsIntent.intent));

    assertEquals("Menu should contain 2 items", 2, config.menuItems.size());
    final String s = config.menuItems.get(0).name;
    assertEquals("Unexpected menu item",
            "menuitem1", config.menuItems.get(0).name);
    assertEquals("Unexpected menu item",
            "menuitem2", config.menuItems.get(1).name);
}
 
开发者ID:mozilla-mobile,项目名称:focus-android,代码行数:22,代码来源:CustomTabConfigTest.java

示例8: malformedActionButtonConfig

import android.support.customtabs.CustomTabsIntent; //导入方法依赖的package包/类
@Test
public void malformedActionButtonConfig() throws Exception {
    final CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
    final CustomTabsIntent customTabsIntent = builder.build();

    final Bundle garbage = new Bundle();
    garbage.putParcelable("foobar", new UnparcelableParcel());
    customTabsIntent.intent.putExtra(CustomTabsIntent.EXTRA_ACTION_BUTTON_BUNDLE, garbage);

    // We should still detect that this is a custom tab
    assertTrue(CustomTabConfig.isCustomTabIntent(new SafeIntent(customTabsIntent.intent)));

    // And we still don't crash
    final CustomTabConfig.ActionButtonConfig actionButtonConfig = CustomTabConfig.getActionButtonConfig(RuntimeEnvironment.application, new SafeIntent(customTabsIntent.intent));

    // But we weren't able to read the action button data because of the unparcelable data
    assertNull(actionButtonConfig);
}
 
开发者ID:mozilla-mobile,项目名称:focus-android,代码行数:19,代码来源:CustomTabConfigTest.java

示例9: openCustomTab

import android.support.customtabs.CustomTabsIntent; //导入方法依赖的package包/类
public static void openCustomTab(Activity activity,
                                 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
    // 只有 16+版本可以用 custom tabs
    if (packageName == null || Build.VERSION.SDK_INT < 16) {
        if (fallback != null) {
            fallback.openUri(activity, uri);
        }
    } else {
        CustomTabsIntent.Builder intentBuilder = new CustomTabsIntent.Builder();
        int color = ThemeUtil.getThemeColor(activity, R.attr.colorPrimary);
        intentBuilder.setToolbarColor(color);
        intentBuilder.setShowTitle(true);
        intentBuilder.setStartAnimations(activity, R.anim.slide_in_right, R.anim.slide_out_left);
        intentBuilder.setExitAnimations(activity, android.R.anim.slide_in_left,
                android.R.anim.slide_out_right);
        CustomTabsIntent customTabsIntent = intentBuilder.build();
        customTabsIntent.intent.setPackage(packageName);
        customTabsIntent.launchUrl(activity, uri);
    }
}
 
开发者ID:goodev,项目名称:droidddle,代码行数:26,代码来源:CustomTabActivityHelper.java

示例10: openWebsite

import android.support.customtabs.CustomTabsIntent; //导入方法依赖的package包/类
/**
 * "Open Website" button click listener. Opens makeapede.com in a Chrome Custom Tab.
 *
 * @param view the clicked view
 */
public void openWebsite(View view) {
	String url = "http://makeapede.com/";
	CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
	CustomTabsIntent customTabsIntent = builder.build();
	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
		builder.setToolbarColor(getColor(R.color.colorPrimary));
	} else {
		builder.setToolbarColor(0x91cf34);
	}
	customTabsIntent.launchUrl(this, Uri.parse(url));
}
 
开发者ID:Make-A-Pede,项目名称:Make-A-Pede-Android-App,代码行数:17,代码来源:HomeActivity.java

示例11: openUrl

import android.support.customtabs.CustomTabsIntent; //导入方法依赖的package包/类
/**
 * Opens the {@code url} using the method the user has set in their preferences (custom tabs,
 * internal, external) falling back as needed
 *
 * @param url             URL to open
 * @param color           Color to provide to the browser UI if applicable
 * @param contextActivity The current activity
 */
public static void openUrl(@NonNull String url, int color, @NonNull Activity contextActivity) {
    if (!SettingValues.web) {
        // External browser
        MainActivity.defaultShare(url, contextActivity);
        return;
    }

    String packageName = CustomTabsHelper.getPackageNameToUse(contextActivity);

    if (packageName != null) {
        Intent intent = new Intent(contextActivity, MakeExternal.class);
        intent.putExtra(Website.EXTRA_URL, url);
        PendingIntent pendingIntent = PendingIntent.getActivity(contextActivity, 0, intent, 0);

        CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder(getSession())
                .setToolbarColor(color)
                .setShowTitle(true)
                .setStartAnimations(contextActivity, R.anim.slide_up_fade_in, 0)
                .setExitAnimations(contextActivity, 0, R.anim.slide_down_fade_out)
                .addDefaultShareMenuItem()
                .addMenuItem(contextActivity.getString(R.string.open_links_externally), pendingIntent)
                .setCloseButtonIcon(drawableToBitmap(ContextCompat.getDrawable(contextActivity, R.drawable.ic_arrow_back_white_24dp)));
        try {
            CustomTabsIntent customTabsIntent = builder.build();

            customTabsIntent.intent.setPackage(packageName);
            customTabsIntent.launchUrl(contextActivity, formatURL(url));
        } catch (ActivityNotFoundException anfe) {
            Log.w(LogUtil.getTag(), "Unknown url: " + anfe);
            MainActivity.defaultShare(url, contextActivity);
        }
    } else {
        // Internal browser
        Intent i = new Intent(contextActivity, Website.class);
        i.putExtra(Website.EXTRA_URL, url);
        i.putExtra(Website.EXTRA_COLOR, color);
        contextActivity.startActivity(i);
    }
}
 
开发者ID:ccrama,项目名称:Slide-RSS,代码行数:48,代码来源:LinkUtil.java

示例12: AboutPresenter

import android.support.customtabs.CustomTabsIntent; //导入方法依赖的package包/类
public AboutPresenter(AppCompatActivity activity, AboutContract.View view) {
    this.activity = activity;
    this.view = view;
    this.view.setPresenter(this);
    sp = activity.getSharedPreferences("user_settings",MODE_PRIVATE);

    customTabsIntent = new CustomTabsIntent.Builder();
    customTabsIntent.setToolbarColor(activity.getResources().getColor(R.color.colorPrimary));
    customTabsIntent.setShowTitle(true);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:11,代码来源:AboutPresenter.java

示例13: openUrl

import android.support.customtabs.CustomTabsIntent; //导入方法依赖的package包/类
@Override
public void openUrl(WebView webView, String url) {
    if (sp.getBoolean("in_app_browser",true)) {
        CustomTabsIntent.Builder customTabsIntent = new CustomTabsIntent.Builder()
                .setToolbarColor(context.getResources().getColor(R.color.colorAccent))
                .setShowTitle(true);
        CustomTabActivityHelper.openCustomTab(
                (Activity) context,
                customTabsIntent.build(),
                Uri.parse(url),
                new CustomFallback() {
                    @Override
                    public void openUri(Activity activity, Uri uri) {
                        super.openUri(activity, uri);
                    }
                }
        );
    } else {

        try{
            context.startActivity(new Intent(Intent.ACTION_VIEW).setData(Uri.parse(url)));
        } catch (android.content.ActivityNotFoundException ex){
            view.showBrowserNotFoundError();
        }

    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:28,代码来源:DetailPresenter.java

示例14: showWeb

import android.support.customtabs.CustomTabsIntent; //导入方法依赖的package包/类
/**
 * Shows a web in a different screen.
 * Once the web is opened, we loose the control of the script
 *
 * @param url
 * @status TOREVIEW
 * @advanced
 */
@ProtoMethod
public void showWeb(String url) {
    CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
    builder.setToolbarColor(Color.BLUE);
    builder.addDefaultShareMenuItem();
    builder.setInstantAppsEnabled(true);

    // builder.setStartAnimations(this, R.anim.slide_in_right, R.anim.slide_out_left);
    // builder.setExitAnimations(this, R.anim.slide_in_left, R.anim.slide_out_right);

    CustomTabsIntent customTabsIntent = builder.build();
    customTabsIntent.launchUrl(getActivity(), Uri.parse(url));
}
 
开发者ID:victordiaz,项目名称:phonk,代码行数:22,代码来源:PUI.java

示例15: onRedirectRequired

import android.support.customtabs.CustomTabsIntent; //导入方法依赖的package包/类
@Override
public void onRedirectRequired(@NonNull final PaymentRequest paymentRequest, final String redirectUrl,
                               @NonNull final UriCallback returnUriCallback) {
    Log.d(TAG, "paymentRequestDetailsListener.onRedirectRequired(): " + redirectUrl);
    uriCallback = returnUriCallback;
    CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
    CustomTabsIntent customTabsIntent = builder.build();
    customTabsIntent.launchUrl(context, Uri.parse(redirectUrl));
}
 
开发者ID:Adyen,项目名称:adyen-android,代码行数:10,代码来源:MainActivity.java


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