當前位置: 首頁>>代碼示例>>Java>>正文


Java CustomTabsSession類代碼示例

本文整理匯總了Java中android.support.customtabs.CustomTabsSession的典型用法代碼示例。如果您正苦於以下問題:Java CustomTabsSession類的具體用法?Java CustomTabsSession怎麽用?Java CustomTabsSession使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


CustomTabsSession類屬於android.support.customtabs包,在下文中一共展示了CustomTabsSession類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: launchCustomTabsWithSessionBottombar

import android.support.customtabs.CustomTabsSession; //導入依賴的package包/類
public void launchCustomTabsWithSessionBottombar(Activity activity, String url, @Nullable CustomTabsSession session) {
    String packageName = CustomTabsHelper.getPackageNameToUse(activity);
    if (TextUtils.isEmpty(packageName)) {
        activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
    }
    CustomTabsIntent.Builder builder;
    if (session == null) {
        builder = new CustomTabsIntent.Builder();
    } else {
        builder = new CustomTabsIntent.Builder(session);
    }

    // Intent hacked
    Intent cctIntent = new CustomTabsIntent.Builder(session).build().intent;
    cctIntent.setData(Uri.parse(url));
    PendingIntent cctPendingIntent = PendingIntent.getActivity(activity, 124, cctIntent, PendingIntent.FLAG_UPDATE_CURRENT);

    addSessionBottombar(builder, activity, cctPendingIntent);

    CustomTabsIntent customTabsIntent = builder
            .setToolbarColor(Color.WHITE)
            .build();
    CustomTabsHelper.addKeepAliveExtra(activity, customTabsIntent.intent);
    customTabsIntent.intent.setPackage(packageName);
    customTabsIntent.launchUrl(activity, Uri.parse(url));
}
 
開發者ID:sakebook,項目名稱:CustomTabsSample,代碼行數:27,代碼來源:AdvanceActivity.java

示例2: createSession

import android.support.customtabs.CustomTabsSession; //導入依賴的package包/類
/**
 * Creates a {@link android.support.customtabs.CustomTabsSession custom tab session} for
 * use with a custom tab intent, with optional callbacks and optional list of URIs that may
 * be requested. The URI list should be ordered such that the most likely URI to be requested
 * is first. If no custom tab supporting browser is available, this will return {@code null}.
 */
@WorkerThread
@Nullable
public CustomTabsSession createSession(
        @Nullable CustomTabsCallback callbacks,
        @Nullable Uri... possibleUris) {
    CustomTabsClient client = getClient();
    if (client == null) {
        return null;
    }

    CustomTabsSession session = client.newSession(callbacks);

    if (possibleUris != null && possibleUris.length > 0) {
        List<Bundle> additionalUris = UriUtil.toCustomTabUriBundle(possibleUris, 1);
        session.mayLaunchUrl(possibleUris[0], null, additionalUris);
    }

    return session;
}
 
開發者ID:openid,項目名稱:AppAuth-Android,代碼行數:26,代碼來源:CustomTabManager.java

示例3: getCustomTabIntent

import android.support.customtabs.CustomTabsSession; //導入依賴的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:liulinbo,項目名稱:Amumu,代碼行數:19,代碼來源:DesignerNewsStory.java

示例4: openExternal

import android.support.customtabs.CustomTabsSession; //導入依賴的package包/類
public static void openExternal(@NonNull final Context context,
                         @NonNull PopupMenu popupMenu,
                         @NonNull View anchor,
                         @NonNull final WebItem item,
                         final CustomTabsSession session) {
    if (TextUtils.isEmpty(item.getUrl()) ||
            item.getUrl().startsWith(HackerNewsClient.BASE_WEB_URL)) {
        openWebUrlExternal(context,
                item, String.format(HackerNewsClient.WEB_ITEM_PATH, item.getId()),
                session);
        return;
    }
    popupMenu.create(context, anchor, GravityCompat.END)
            .inflate(R.menu.menu_share)
            .setOnMenuItemClickListener(menuItem -> {
                openWebUrlExternal(context, item, menuItem.getItemId() == R.id.menu_article ?
                        item.getUrl() :
                        String.format(HackerNewsClient.WEB_ITEM_PATH, item.getId()), session);
                return true;
            })
            .show();
}
 
開發者ID:hidroh,項目名稱:materialistic,代碼行數:23,代碼來源:AppUtils.java

示例5: createViewIntent

import android.support.customtabs.CustomTabsSession; //導入依賴的package包/類
@NonNull
private static Intent createViewIntent(Context context, @Nullable WebItem item,
                                       String url, @Nullable CustomTabsSession session) {
    if (Preferences.customTabsEnabled(context)) {
        CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder(session)
                .setToolbarColor(ContextCompat.getColor(context,
                        AppUtils.getThemedResId(context, R.attr.colorPrimary)))
                .setShowTitle(true)
                .enableUrlBarHiding()
                .addDefaultShareMenuItem();
        if (item != null) {
            builder.addMenuItem(context.getString(R.string.comments),
                    PendingIntent.getActivity(context, 0,
                            new Intent(context, ItemActivity.class)
                                    .putExtra(ItemActivity.EXTRA_ITEM, item)
                                    .putExtra(ItemActivity.EXTRA_OPEN_COMMENTS, true),
                            PendingIntent.FLAG_ONE_SHOT));
        }
        return builder.build().intent.setData(Uri.parse(url));
    } else {
        return new Intent(Intent.ACTION_VIEW, Uri.parse(url));
    }
}
 
開發者ID:hidroh,項目名稱:materialistic,代碼行數:24,代碼來源:AppUtils.java

示例6: onReceive

import android.support.customtabs.CustomTabsSession; //導入依賴的package包/類
@Override
public void onReceive(Context context, Intent intent) {
    int clickedId = intent.getIntExtra(CustomTabsIntent.EXTRA_REMOTEVIEWS_CLICKED_ID, -1);
    Toast.makeText(context, "Current URL " + intent.getDataString() + "\nClicked id "
            + clickedId, Toast.LENGTH_SHORT).show();

    CustomTabsSession session = SessionHelper.getCurrentSession();
    if (session == null) return;

    if (clickedId == R.id.play_pause) {
        MediaPlayer player = sMediaPlayerWeakRef.get();
        if (player != null) {
            boolean isPlaying = player.isPlaying();
            if (isPlaying) player.pause();
            else player.start();
            // Update the play/stop icon to respect the current state.
            session.setSecondaryToolbarViews(createRemoteViews(context, isPlaying), getClickableIDs(),
                    getOnClickPendingIntent(context));
        }
    } else if (clickedId == R.id.cover) {
        // Clicking on the cover image will dismiss the bottom bar.
        session.setSecondaryToolbarViews(null, null, null);
    }
}
 
開發者ID:GoogleChrome,項目名稱:custom-tabs-client,代碼行數:25,代碼來源:BottomBarManager.java

示例7: getCustomTabIntent

import android.support.customtabs.CustomTabsSession; //導入依賴的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(DrawableUtils.drawableToBitmap(context,
                            R.drawable.ic_upvote_filled_24dp_white),
                    context.getString(R.string.upvote_story),
                    pendingIntent,
                    false)
            .setShowTitle(true)
            .enableUrlBarHiding()
            .addDefaultShareMenuItem();
}
 
開發者ID:nickbutcher,項目名稱:plaid,代碼行數:19,代碼來源:DesignerNewsStory.java

示例8: preload

import android.support.customtabs.CustomTabsSession; //導入依賴的package包/類
/** Caller must unbind the returned ServiceConnection when leaving the scope. */
public static @CheckResult @Nullable ServiceConnection preload(final Context context, final Uri uri, final @Nullable OnSessionReadyListener listener) {
	final CustomTabsServiceConnection connection;
	if (! CustomTabsClient.bindCustomTabsService(context, KChromePackageName, connection = new CustomTabsServiceConnection() {

		@Override public void onCustomTabsServiceConnected(final ComponentName componentName, final CustomTabsClient client) {
			Log.d(TAG, "Warming up Chrome custom tabs");
			if (client.warmup(0)) {
				final CustomTabsSession session = client.newSession(null);
				if (session != null) {
					session.mayLaunchUrl(uri, null, null);
					if (listener != null) listener.onSessionReady(session);
				}
			}
		}

		@Override public void onServiceDisconnected(final ComponentName name) {}
	})) return null;
	return connection;
}
 
開發者ID:oasisfeng,項目名稱:deagle,代碼行數:21,代碼來源:WebContent.java

示例9: getSession

import android.support.customtabs.CustomTabsSession; //導入依賴的package包/類
/**
 * Creates or retrieves an exiting CustomTabsSession.
 *
 * @return a CustomTabsSession.
 */
public CustomTabsSession getSession() {
    if (mClient == null) {
        mCustomTabsSession = null;
    } else if (mCustomTabsSession == null) {
        mCustomTabsSession = mClient.newSession(null);
    }
    return mCustomTabsSession;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:14,代碼來源:CustomTabActivityHelper.java

示例10: mayLaunchUrl

import android.support.customtabs.CustomTabsSession; //導入依賴的package包/類
/**
 * @see {@link CustomTabsSession#mayLaunchUrl(Uri, Bundle, List)}.
 * @return true if call to mayLaunchUrl was accepted.
 */
public boolean mayLaunchUrl(Uri uri, Bundle extras, List<Bundle> otherLikelyBundles) {
    if (mClient == null) return false;

    CustomTabsSession session = getSession();
    if (session == null) return false;

    return session.mayLaunchUrl(uri, extras, otherLikelyBundles);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:13,代碼來源:CustomTabActivityHelper.java

示例11: getSession

import android.support.customtabs.CustomTabsSession; //導入依賴的package包/類
/**
 * Creates or retrieves an exiting CustomTabsSession.
 *
 * @return a CustomTabsSession.
 */
public CustomTabsSession getSession() {
  if (mClient == null) {
    mCustomTabsSession = null;
  } else if (mCustomTabsSession == null) {
    mCustomTabsSession = mClient.newSession(null);
  }
  return mCustomTabsSession;
}
 
開發者ID:tomoya92,項目名稱:android-apps,代碼行數:14,代碼來源:CustomTabActivityHelper.java

示例12: mayLaunchUrl

import android.support.customtabs.CustomTabsSession; //導入依賴的package包/類
/**
 * @return true if call to mayLaunchUrl was accepted.
 * @see {@link CustomTabsSession#mayLaunchUrl(Uri, Bundle, List)}.
 */
public boolean mayLaunchUrl(Uri uri, Bundle extras, List<Bundle> otherLikelyBundles) {
  if (mClient == null) return false;

  CustomTabsSession session = getSession();
  if (session == null) return false;

  return session.mayLaunchUrl(uri, extras, otherLikelyBundles);
}
 
開發者ID:tomoya92,項目名稱:android-apps,代碼行數:13,代碼來源:CustomTabActivityHelper.java

示例13: getSession

import android.support.customtabs.CustomTabsSession; //導入依賴的package包/類
public static CustomTabsSession getSession() {
    if (mClient == null) {
        mCustomTabsSession = null;
    } else if (mCustomTabsSession == null) {
        mCustomTabsSession = mClient.newSession(new CustomTabsCallback() {
            @Override
            public void onNavigationEvent(int navigationEvent, Bundle extras) {
                Log.w(LogUtil.getTag(), "onNavigationEvent: Code = " + navigationEvent);
            }
        });
    }
    return mCustomTabsSession;
}
 
開發者ID:ccrama,項目名稱:Slide-RSS,代碼行數:14,代碼來源:LinkUtil.java

示例14: getSession

import android.support.customtabs.CustomTabsSession; //導入依賴的package包/類
/**
 * Creates or retrieves an exiting CustomTabsSession
 *
 * @return a CustomTabsSession
 */
public CustomTabsSession getSession() {
    if (client == null) {
        customTabsSession = null;
    } else if (customTabsSession == null) {
        customTabsSession = client.newSession(null);
    }
    return customTabsSession;
}
 
開發者ID:saschpe,項目名稱:android-customtabs,代碼行數:14,代碼來源:CustomTabsHelper.java

示例15: mayLaunchUrl

import android.support.customtabs.CustomTabsSession; //導入依賴的package包/類
public boolean mayLaunchUrl(final Uri uri, final Bundle extras, final List<Bundle> otherLikelyBundles) {
    if (client == null) {
        return false;
    }
    CustomTabsSession session = getSession();
    return session != null && session.mayLaunchUrl(uri, extras, otherLikelyBundles);
}
 
開發者ID:saschpe,項目名稱:android-customtabs,代碼行數:8,代碼來源:CustomTabsHelper.java


注:本文中的android.support.customtabs.CustomTabsSession類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。