Java Code Examples for android.os.Build.VERSION#SDK_INT

The following examples show how to use android.os.Build.VERSION#SDK_INT . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ContactPhotoLocalUriFetcher.java    From mollyim-android with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected InputStream loadResource(Uri uri, ContentResolver contentResolver)
    throws FileNotFoundException
{
  if (VERSION.SDK_INT >= VERSION_CODES.ICE_CREAM_SANDWICH) {
    return ContactsContract.Contacts.openContactPhotoInputStream(contentResolver, uri, true);
  } else {
    return ContactsContract.Contacts.openContactPhotoInputStream(contentResolver, uri);
  }
}
 
Example 2
Source File: Util.java    From mollyim-android with GNU General Public License v3.0 6 votes vote down vote up
@TargetApi(VERSION_CODES.KITKAT)
public static boolean isLowMemory(Context context) {
  ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);

  return (VERSION.SDK_INT >= VERSION_CODES.KITKAT && activityManager.isLowRamDevice()) ||
         activityManager.getLargeMemoryClass() <= 64;
}
 
Example 3
Source File: TextureRenderView.java    From FimiX8-RE with MIT License 6 votes vote down vote up
@TargetApi(16)
public void bindToMediaPlayer(IMediaPlayer mp) {
    if (mp != null) {
        if (VERSION.SDK_INT < 16 || !(mp instanceof ISurfaceTextureHolder)) {
            mp.setSurface(openSurface());
            return;
        }
        ISurfaceTextureHolder textureHolder = (ISurfaceTextureHolder) mp;
        this.mTextureView.mSurfaceCallback.setOwnSurfaceTecture(false);
        SurfaceTexture surfaceTexture = textureHolder.getSurfaceTexture();
        if (surfaceTexture != null) {
            this.mTextureView.setSurfaceTexture(surfaceTexture);
        } else {
            textureHolder.setSurfaceTexture(this.mSurfaceTexture);
        }
    }
}
 
Example 4
Source File: FimiMediaCodecInfo.java    From FimiX8-RE with MIT License 6 votes vote down vote up
@TargetApi(16)
public void dumpProfileLevels(String mimeType) {
    if (VERSION.SDK_INT >= 16) {
        try {
            CodecCapabilities caps = this.mCodecInfo.getCapabilitiesForType(mimeType);
            int maxProfile = 0;
            int maxLevel = 0;
            if (!(caps == null || caps.profileLevels == null)) {
                for (CodecProfileLevel profileLevel : caps.profileLevels) {
                    if (profileLevel != null) {
                        maxProfile = Math.max(maxProfile, profileLevel.profile);
                        maxLevel = Math.max(maxLevel, profileLevel.level);
                    }
                }
            }
            Log.i(TAG, String.format(Locale.US, "%s", new Object[]{getProfileLevelName(maxProfile, maxLevel)}));
        } catch (Throwable th) {
            Log.i(TAG, "profile-level: exception");
        }
    }
}
 
Example 5
Source File: EmojiProvider.java    From mollyim-android with GNU General Public License v3.0 6 votes vote down vote up
@TargetApi(VERSION_CODES.HONEYCOMB_MR1)
public void setBitmap(Bitmap bitmap) {
  Util.assertMainThread();
  if (VERSION.SDK_INT < VERSION_CODES.HONEYCOMB_MR1 || bmp == null || !bmp.sameAs(bitmap)) {
    bmp = bitmap;
    invalidateSelf();
  }
}
 
Example 6
Source File: Compat.java    From giffun with Apache License 2.0 6 votes vote down vote up
public static void postOnAnimation(View view, Runnable runnable) {
    if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) {
        postOnAnimationJellyBean(view, runnable);
    } else {
        view.postDelayed(runnable, SIXTY_FPS_INTERVAL);
    }
}
 
Example 7
Source File: StatusBarUtil.java    From FimiX8-RE with MIT License 6 votes vote down vote up
@Deprecated
public static void setTranslucentForDrawerLayoutDiff(Activity activity, DrawerLayout drawerLayout) {
    if (VERSION.SDK_INT >= 19) {
        activity.getWindow().addFlags(NTLMConstants.FLAG_UNIDENTIFIED_9);
        ViewGroup contentLayout = (ViewGroup) drawerLayout.getChildAt(0);
        contentLayout.setFitsSystemWindows(true);
        contentLayout.setClipToPadding(true);
        ((ViewGroup) drawerLayout.getChildAt(1)).setFitsSystemWindows(false);
        drawerLayout.setFitsSystemWindows(false);
    }
}
 
Example 8
Source File: SegmentedButton.java    From SegmentedButton with Apache License 2.0 5 votes vote down vote up
private Drawable readCompatDrawable(Context context, int drawableResId)
{
    Drawable drawable = AppCompatResources.getDrawable(context, drawableResId);

    // API 28 has a bug with vector drawables where the selected tint color is always applied to the drawable
    // To prevent this, the vector drawable is converted to a bitmap
    if ((VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP && drawable instanceof VectorDrawable)
        || drawable instanceof VectorDrawableCompat)
    {
        Bitmap bitmap = getBitmapFromVectorDrawable(drawable);
        return new BitmapDrawable(context.getResources(), bitmap);
    }
    else
        return drawable;
}
 
Example 9
Source File: SecurePreferences.java    From FimiX8-RE with MIT License 5 votes vote down vote up
@TargetApi(9)
public void apply() {
    if (VERSION.SDK_INT >= 9) {
        this.mEditor.apply();
    } else {
        commit();
    }
}
 
Example 10
Source File: StatusBarUtil.java    From FimiX8-RE with MIT License 5 votes vote down vote up
public static boolean isNotch(Context context) {
    if (VERSION.SDK_INT < 19) {
        return false;
    }
    if ("Xiaomi".equals(Build.BRAND)) {
        return hasNotchInScreenAtMi(context);
    }
    return hasNotchInScreen(context);
}
 
Example 11
Source File: Compat.java    From star-zone-android with Apache License 2.0 5 votes vote down vote up
public static void postOnAnimation(View view, Runnable runnable) {
    if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) {
        postOnAnimationJellyBean(view, runnable);
    } else {
        view.postDelayed(runnable, SIXTY_FPS_INTERVAL);
    }
}
 
Example 12
Source File: LanguageUtil.java    From FimiX8-RE with MIT License 5 votes vote down vote up
@TargetApi(24)
private static Context updateResources(Context context, Locale locale2) {
    Resources resources = context.getResources();
    Locale locale = getLocaleByLanguage(locale2);
    Configuration configuration = resources.getConfiguration();
    if (VERSION.SDK_INT >= 24) {
        configuration.setLocale(locale);
        configuration.setLocales(new LocaleList(new Locale[]{locale}));
    } else {
        configuration.setLocale(locale);
    }
    return context.createConfigurationContext(configuration);
}
 
Example 13
Source File: PermissionManager.java    From FimiX8-RE with MIT License 5 votes vote down vote up
public static final boolean isLocationEnable(Context context) {
    if (VERSION.SDK_INT < 23) {
        return true;
    }
    LocationManager locationManager = (LocationManager) context.getSystemService("location");
    boolean networkProvider = locationManager.isProviderEnabled(BlockInfo.KEY_NETWORK);
    boolean gpsProvider = locationManager.isProviderEnabled("gps");
    if (networkProvider || gpsProvider) {
        return true;
    }
    return false;
}
 
Example 14
Source File: SegmentedButton.java    From SegmentedButton with Apache License 2.0 5 votes vote down vote up
/**
 * Set ripple color used for ripple effect on button press
 *
 * @param color color to set for the ripple effect for this button
 */
public void setRipple(@ColorInt int color)
{
    rippleColor = color;

    if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP)
    {
        rippleDrawableLollipop = new RippleDrawable(ColorStateList.valueOf(rippleColor), null, null);
        // setCallback on Drawable allows animations to be scheduled and the drawable to invalidate the view on
        // animation
        rippleDrawableLollipop.setCallback(this);
        rippleDrawableLollipop.setBounds(0, 0, getWidth(), getHeight());

        // Disable/nullify the pre-lollipop RippleDrawable backport
        rippleDrawable = null;
    }
    else
    {
        rippleDrawable = new codetail.graphics.drawables.RippleDrawable(ColorStateList.valueOf(rippleColor), null,
            null);
        // setCallback on Drawable allows animations to be scheduled and the drawable to invalidate the view on
        // animation
        rippleDrawable.setCallback(this);
        rippleDrawable.setBounds(0, 0, getWidth(), getHeight());

        setOnTouchListener(new DrawableHotspotTouch(rippleDrawable));

        // Disable/nullify the lollipop RippleDrawable
        rippleDrawableLollipop = null;
    }

    invalidate();
}
 
Example 15
Source File: FermiPlayerUtils.java    From FimiX8-RE with MIT License 5 votes vote down vote up
public static Bitmap createVideoThumbnail(String filePath, int offsetMillSecond) {
    filePath = filePath.replace("file://", "");
    if (VERSION.SDK_INT < 14) {
        return createVideoThumbnail(filePath);
    }
    MediaMetadataRetriever retriever = new MediaMetadataRetriever();
    retriever.setDataSource(filePath);
    return retriever.getFrameAtTime((long) (offsetMillSecond * 1000), 2);
}
 
Example 16
Source File: StatusBarUtil.java    From FimiX8-RE with MIT License 4 votes vote down vote up
public static void setTranslucentForCoordinatorLayout(Activity activity, int statusBarAlpha) {
    if (VERSION.SDK_INT >= 19) {
        transparentStatusBar(activity);
        addTranslucentView(activity, statusBarAlpha);
    }
}
 
Example 17
Source File: X8TabItem.java    From FimiX8-RE with MIT License 4 votes vote down vote up
private void sove() {
    GradientDrawable dd = new GradientDrawable();
    dd.setCornerRadii(new float[]{(float) this.radius, (float) this.radius, (float) this.radius, (float) this.radius, (float) this.radius, (float) this.radius, (float) this.radius, (float) this.radius});
    dd.setStroke(this.lineStroke, this.lineColor);
    if (VERSION.SDK_INT >= 16) {
        setBackground(dd);
    } else {
        setBackgroundDrawable(dd);
    }
    removeAllViews();
    if (this.curIndex >= this.textArr.length || this.curIndex < 0) {
        this.curIndex = 0;
    }
    for (int i = 0; i < this.textArr.length; i++) {
        TextView tv = new TextView(getContext());
        LayoutParams params = new LayoutParams(0, -1);
        if (i > 0) {
            params.leftMargin = this.space;
        }
        GradientDrawable d = getFitGradientDrawable(i);
        if (this.curIndex == i) {
            tv.setTextColor(this.selectTextColor);
            d.setColor(this.selectTabBg);
        } else {
            tv.setTextColor(this.unSelectTextColor);
            d.setColor(this.unSelectTabBg);
        }
        tv.setText(this.textArr[i]);
        tv.setGravity(17);
        tv.setTextSize(0, this.textSize);
        if (VERSION.SDK_INT >= 16) {
            tv.setBackground(d);
        } else {
            tv.setBackgroundDrawable(d);
        }
        params.weight = 1.0f;
        tv.setLayoutParams(params);
        tv.setTag(Integer.valueOf(i));
        tv.setOnClickListener(this);
        addView(tv);
    }
}
 
Example 18
Source File: StatusBarUtil.java    From FimiX8-RE with MIT License 4 votes vote down vote up
public static void setTranslucent(Activity activity, int statusBarAlpha) {
    if (VERSION.SDK_INT >= 19) {
        setTransparent(activity);
        addTranslucentView(activity, statusBarAlpha);
    }
}
 
Example 19
Source File: StatusBarUtil.java    From FimiX8-RE with MIT License 4 votes vote down vote up
public static void setTranslucentForDrawerLayout(Activity activity, DrawerLayout drawerLayout, int statusBarAlpha) {
    if (VERSION.SDK_INT >= 19) {
        setTransparentForDrawerLayout(activity, drawerLayout);
        addTranslucentView(activity, statusBarAlpha);
    }
}
 
Example 20
Source File: OpenApplication.java    From za-Farmer with MIT License 4 votes vote down vote up
@Override
protected void runSelf() throws Exception {

    //Part One 输入app版本log

    PackageInfo info = InstrumentationRegistry.getContext().getPackageManager().getPackageInfo(this.getPackageName(), 0);
    String appversion = info.versionName;
    LogUtils.getInstance().info("appversion" + appversion);


    int sdk = VERSION.SDK_INT;

    if (this.clear) {
        //清掉缓存

        if (sdk < 21) {
            //清缓存待定
            LogUtils.getInstance().info("sdk版本小于api21,清缓后续处理");
        } else {

            String clearoutput = getUiDevice().executeShellCommand("pm clear " + this.getPackageName());
            LogUtils.getInstance().info("pm clear " + clearoutput);
        }
    }


    Context mContext = InstrumentationRegistry.getContext();
    Intent myIntent = mContext.getPackageManager().getLaunchIntentForPackage(this.getPackageName());
    String AppStartActivity = myIntent.getComponent().getClassName();

    if (sdk < 21) {
        //安卓版本5.0以下的启动方式
        mContext.startActivity(myIntent);

    } else {
        //安卓版本5.0以上的启动方式
        String startNoClearoutput = getUiDevice().executeShellCommand("am start -n " + this.getPackageName() + "/" + AppStartActivity);
        LogUtils.getInstance().info(startNoClearoutput);
    }

    BySelector bySelector = By.base();
    bySelector.pkg(this.getPackageName());
    getElement(bySelector, 10000);


    screenshot(TYPE_LOG_SUCCESS);

}