當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。