Android MediaRouter - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android MediaRouter class.

This code example shows how to use the following methods:removeCallback
  @Override 
  protected void onPause() { 
    clearPreso(false); 
 
    if (router != null) {
      router.removeCallback(cb);
    } 
 
    super.onPause(); 
  } 
 
  private void handleRoute(RouteInfo route) {
    if (route == null) {
      clearPreso(true); 
    } 
    else { 
      Display display=route.getPresentationDisplay();
 
      if (route.isEnabled() && display != null) {
        if (preso == null) {
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:addCallback, getSelectedRoute
    protected void onResume() { 
        // Be sure to call the super class. 
        super.onResume(); 
 
        // Listen for changes to media routes. 
        mMediaRouter.addCallback(MediaRouter.ROUTE_TYPE_LIVE_VIDEO, mMediaRouterCallback);
 
        // Update the presentation based on the currently selected route. 
        mPaused = false;
        updatePresentation(); 
    } 
 
    @Override 
    protected void onPause() { 
        // Be sure to call the super class. 
        super.onPause(); 
 
        // Stop listening for changes to media routes. 
        mMediaRouter.removeCallback(mMediaRouterCallback);
 

6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:removeCallback
  protected void onPause() { 
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
      clearPreso(); 
 
      if (router != null) {
        router.removeCallback(cb);
      } 
    } 
 
    super.onPause(); 
  } 
 
  @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
  private void handleRoute(RouteInfo route) {
    if (route == null) {
      clearPreso(); 
    } 
    else { 
      Display display=route.getPresentationDisplay();
 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getSelectedRoute
    } 
 
    void changeVolume(int newValue) {
        if (mIgnoreSliderVolumeChanges) return;
 
        final RouteInfo selectedRoute = mRouter.getSelectedRoute(mRouteTypes);
        if (selectedRoute.getVolumeHandling() == RouteInfo.PLAYBACK_VOLUME_VARIABLE) {
            final int maxVolume = selectedRoute.getVolumeMax();
            newValue = Math.max(0, Math.min(newValue, maxVolume));
            selectedRoute.requestSetVolume(newValue);
        } 
    } 
 
    @Override 
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        mInflater = inflater;
        final View layout = inflater.inflate(R.layout.media_route_chooser_layout, container, false);
 
        mVolumeIcon = (ImageView) layout.findViewById(R.id.volume_icon);
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:selectRouteInt
                // a groupable category, where every top-level route in the category is a group. 
                final RouteGroup group = (RouteGroup) getItem(position);
                mEditingGroup = group;
                mCategoryEditingGroups = group.getCategory();
                getDialog().setCanceledOnTouchOutside(false);
                mRouter.selectRouteInt(mRouteTypes, mEditingGroup);
                update(); 
                scrollToEditingGroup(); 
            } 
        } 
    } 
 
    class MediaRouterCallback extends MediaRouter.Callback {
        @Override 
        public void onRouteSelected(MediaRouter router, int type, RouteInfo info) {
            mAdapter.update();
            updateVolume(); 
        } 
 
        @Override 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:addCallback, getSelectedRoute
    protected void onResume() { 
        // Be sure to call the super class. 
        super.onResume(); 
 
        // Listen for changes to media routes. 
        mMediaRouter.addCallback(MediaRouter.ROUTE_TYPE_LIVE_VIDEO,
                mMediaRouterCallback);
 
        // Update the presentation based on the currently selected route. 
        updatePresentation(); 
    } 
 
    @Override 
    protected void onPause() { 
        // Be sure to call the super class. 
        super.onPause(); 
 
        // Stop listening for changes to media routes. 
        mMediaRouter.removeCallback(mMediaRouterCallback);
 

4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:removeCallback
        } 
        if (mAdapter != null) {
            mAdapter = null;
        } 
        mInflater = null;
        mRouter.removeCallback(mCallback);
        mRouter = null;
    } 
 
    public void setExtendedSettingsClickListener(View.OnClickListener listener) {
        mExtendedSettingsListener = listener;
    } 
 
    public void setRouteTypes(int types) {
        mRouteTypes = types;
    } 
 
    void updateVolume() { 
        if (mRouter == null) return;
 
3
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getSelectedRoute
                if (selectedRoute != null) {
                    selectedRoute.requestUpdateVolume(-1);
                    return true; 
                } 
            } else if (keyCode == KeyEvent.KEYCODE_VOLUME_UP && mVolumeSlider.isEnabled()) {
                final RouteInfo selectedRoute = mRouter.getSelectedRoute(mRouteTypes);
                if (selectedRoute != null) {
                    mRouter.getSelectedRoute(mRouteTypes).requestUpdateVolume(1);
                    return true; 
                } 
            } 
            return super.onKeyDown(keyCode, event);
        } 
 
        public boolean onKeyUp(int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN && mVolumeSlider.isEnabled()) {
                return true; 
            } else if (keyCode == KeyEvent.KEYCODE_VOLUME_UP && mVolumeSlider.isEnabled()) {
                return true; 
            } else { 
4
CodeRank
Experience pair programming with AI  Get Codota for Java

Related Android MediaRouter Questions & Answers:

See Code Examples for Android MediaRouter Methods: