Java Code Examples for android.os.Build

The following examples show how to use android.os.Build. These examples are extracted from open source projects. 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
private void createCardView(ViewHolder holder, List<Point> points) {
    for (int i = 0; i < points.size(); i++) {
        final Point point = points.get(i);
        View pointView = LayoutInflater.from(mContext).inflate(R.layout.carview_review, holder.ly_carview, false);
        TextView pointName = (TextView) pointView.findViewById(R.id.tv_carview);
        CardView cardView = (CardView) pointView.findViewById(R.id.cv_carview);
        //5.0CarView 才支持设置阴影
        if(Build.VERSION.SDK_INT >=21) {
            cardView.setElevation(TDevice.dpToPixel(8));
        }
        cardViewSetBackgroundColor(point, cardView);
        //如果不是无效知识点,则加入点击事件
        if (point.getObjectId() != null) {
            cardView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    startContentList(point);
                }
            });
        }
        pointName.setText(point.getName());
        holder.ly_carview.addView(pointView);
    }
}
 
Example 2
@Override
public void onPanelSlide(View panel, float slideOffset) {
  super.onPanelSlide(panel, slideOffset);
  if (partialView == null || fullView == null) {
    return;
  }

  if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
    if (slideOffset == 1 && !wasOpened) {
      // the layout was just opened, move the partial view off screen
      updatePartialViewVisibilityPreHoneycomb(true);
      wasOpened = true;
    } else if (slideOffset < 1 && wasOpened) {
      // the layout just started to close, move the partial view back, so it can be shown animating
      updatePartialViewVisibilityPreHoneycomb(false);
      wasOpened = false;
    }
  } else {
    partialView.setVisibility(isOpen() ? View.GONE : VISIBLE);
  }
  
  ViewHelper.setAlpha(partialView, 1 - slideOffset);
  ViewHelper.setAlpha(fullView, slideOffset);
}
 
Example 3
Source Project: UberClone   Source File: CustomerMapActivity.java    License: MIT License 5 votes vote down vote up
@Override
public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;

    mLocationRequest = new LocationRequest();
    mLocationRequest.setInterval(1000);
    mLocationRequest.setFastestInterval(1000);
    mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);

    if(android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M){
        if(ContextCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED){

        }else{
            checkLocationPermission();
        }
    }

    mFusedLocationClient.requestLocationUpdates(mLocationRequest, mLocationCallback, Looper.myLooper());
    mMap.setMyLocationEnabled(true);
}
 
Example 4
Source Project: MyBookshelf   Source File: UpdateManager.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * 安装apk
 */
public void installApk(File apkFile) {
    if (!apkFile.exists()) {
        return;
    }
    Intent intent = new Intent();
    //执行动作
    intent.setAction(Intent.ACTION_VIEW);
    //判读版本是否在7.0以上
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        Uri apkUri = FileProvider.getUriForFile(activity, BuildConfig.APPLICATION_ID + ".fileProvider", apkFile);
        intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
        intent.setDataAndType(apkUri, "application/vnd.android.package-archive");
    } else {
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.setDataAndType(Uri.fromFile(apkFile), "application/vnd.android.package-archive");
    }
    try {
        activity.startActivity(intent);
    } catch (Exception e) {
        Log.d("wwd", "Failed to launcher installing activity");
    }
}
 
Example 5
Source Project: talk-android   Source File: TextureRenderView.java    License: MIT License 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public void bindToMediaPlayer(IMediaPlayer mp) {
    if (mp == null)
        return;

    if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) &&
            (mp instanceof ISurfaceTextureHolder)) {
        ISurfaceTextureHolder textureHolder = (ISurfaceTextureHolder) mp;
        mTextureView.mSurfaceCallback.setOwnSurfaceTexture(false);

        SurfaceTexture surfaceTexture = textureHolder.getSurfaceTexture();
        if (surfaceTexture != null) {
            mTextureView.setSurfaceTexture(surfaceTexture);
        } else {
            textureHolder.setSurfaceTexture(mSurfaceTexture);
            textureHolder.setSurfaceTextureHost(mTextureView.mSurfaceCallback);
        }
    } else {
        mp.setSurface(openSurface());
    }
}
 
Example 6
Source Project: DebugDrawer   Source File: DebugDrawer.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * helper to extend the layoutParams of the drawer
 *
 * @param params
 * @return
 */
private DrawerLayout.LayoutParams processDrawerLayoutParams(DrawerLayout.LayoutParams params) {
    if (params != null) {
        if (drawerGravity != 0 && (drawerGravity == Gravity.RIGHT || drawerGravity == Gravity.END)) {
            params.rightMargin = 0;
            if (Build.VERSION.SDK_INT >= 17) {
                params.setMarginEnd(0);
            }

            params.leftMargin = activity.getResources().getDimensionPixelSize(R.dimen.dd_debug_drawer_margin);
            if (Build.VERSION.SDK_INT >= 17) {
                params.setMarginEnd(activity.getResources().getDimensionPixelSize(R.dimen.dd_debug_drawer_margin));
            }
        }

        if (drawerWidth > -1) {
            params.width = drawerWidth;
        } else {
            params.width = UIUtils.getOptimalDrawerWidth(activity);
        }
    }

    return params;
}
 
Example 7
Source Project: ProgressStatusBar   Source File: ProgressStatusBar.java    License: Apache License 2.0 5 votes vote down vote up
private void init() {

        int barColor = Color.parseColor("#60ffffff");
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            barColor = Color.parseColor("#40212121");
        }

        progressPaint = new Paint();
        progressPaint.setStyle(Paint.Style.FILL);
        progressPaint.setColor(barColor);

        windowManager = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);

        params = new WindowManager.LayoutParams(
                WindowManager.LayoutParams.MATCH_PARENT, getStatusBarHeight(getContext()),
                WindowManager.LayoutParams.FIRST_SUB_WINDOW,
                WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                        | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
                        | WindowManager.LayoutParams.FLAG_FULLSCREEN
                        | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
                PixelFormat.TRANSLUCENT);
        params.gravity = Gravity.TOP | Gravity.LEFT;
        
        setBackgroundColor(Color.TRANSPARENT);
        
    }
 
Example 8
Source Project: a   Source File: BlurTransformation.java    License: GNU General Public License v3.0 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
@Override
protected Bitmap transform(@NonNull BitmapPool pool, @NonNull Bitmap toTransform, int outWidth, int outHeight) {
    Bitmap blurredBitmap = toTransform.copy(Bitmap.Config.ARGB_8888, true);

    // Allocate memory for Renderscript to work with
    //分配用于渲染脚本的内存
    Allocation input = Allocation.createFromBitmap(rs, blurredBitmap, Allocation.MipmapControl.MIPMAP_FULL, Allocation.USAGE_SHARED);
    Allocation output = Allocation.createTyped(rs, input.getType());

    // Load up an instance of the specific script that we want to use.
    //加载我们想要使用的特定脚本的实例。
    ScriptIntrinsicBlur script = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
    script.setInput(input);

    // Set the blur radius
    //设置模糊半径
    script.setRadius(radius);

    // Start the ScriptIntrinsicBlur
    //启动 ScriptIntrinsicBlur,
    script.forEach(output);

    // Copy the output to the blurred bitmap
    //将输出复制到模糊的位图
    output.copyTo(blurredBitmap);

    return blurredBitmap;
}
 
Example 9
Source Project: zulip-android   Source File: UnsortedTests.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Run this before each test to set up the activity.
 */
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
private void prepTests() {
    setApplication(app);
    this.startActivity(new Intent(getInstrumentation().getTargetContext(),
            ZulipActivity.class), null, null);
    this.getInstrumentation().waitForIdleSync();
    app.setContext(getInstrumentation().getTargetContext());
    // Need to setEmail twice to reinitialise the database after destroying
    // it.
    app.setEmail(TESTUSER_EXAMPLE_COM);
    app.deleteDatabase(app.getDatabaseHelper().getDatabaseName());
    app.setEmail(TESTUSER_EXAMPLE_COM);
    messageDao = app.getDao(Message.class);

}
 
Example 10
Source Project: LiveMultimedia   Source File: LollipopCamera.java    License: Apache License 2.0 5 votes vote down vote up
/*********************************************************
 * Close the camera.
 ********************************************************/
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public void closeCamera() {
    try {
        mCameraOpenCloseLock.acquire();
        if (null != mCameraDevice) {
            mCameraDevice.close();
            mCameraDevice = null;
        }
        if (null != mMediaRecorder) {
            mMediaRecorder.release();
            mMediaRecorder = null;
        }
    } catch (InterruptedException e) {
        throw new RuntimeException("Interrupted while trying to lock camera closing.");
    } finally {
        mCameraOpenCloseLock.release();
    }
}
 
Example 11
Source Project: stynico   Source File: StatusBarUtil.java    License: MIT License 5 votes vote down vote up
/**
 * 使状态栏透明
 */
@TargetApi(Build.VERSION_CODES.KITKAT)
private static void transparentStatusBar(Activity activity) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
        activity.getWindow().setStatusBarColor(Color.TRANSPARENT);
    } else {
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    }
}
 
Example 12
Source Project: PermissionGen   Source File: PermissionGen.java    License: Apache License 2.0 5 votes vote down vote up
@TargetApi(value = Build.VERSION_CODES.M)
private static void requestPermissions(Object object, int requestCode, String[] permissions){
  if(!Utils.isOverMarshmallow()) {
    doExecuteSuccess(object, requestCode);
    return;
  }
  List<String> deniedPermissions = Utils.findDeniedPermissions(getActivity(object), permissions);

  if(deniedPermissions.size() > 0){
    if(object instanceof Activity){
      ((Activity)object).requestPermissions(deniedPermissions.toArray(new String[deniedPermissions.size()]), requestCode);
    } else if(object instanceof Fragment){
      ((Fragment)object).requestPermissions(deniedPermissions.toArray(new String[deniedPermissions.size()]), requestCode);
    } else {
      throw new IllegalArgumentException(object.getClass().getName() + " is not supported");
    }

  } else {
    doExecuteSuccess(object, requestCode);
  }
}
 
Example 13
Source Project: Focus   Source File: StatusBarUtil.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * 为DrawerLayout 布局设置状态栏变色
 *
 * @param activity       需要设置的activity
 * @param drawerLayout   DrawerLayout
 * @param color          状态栏颜色值
 * @param statusBarAlpha 状态栏透明度
 */
public static void setColorForDrawerLayout(Activity activity, DrawerLayout drawerLayout, @ColorInt int color,
                                           @IntRange(from = 0, to = 255) int statusBarAlpha) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
        return;
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        activity.getWindow().setStatusBarColor(Color.TRANSPARENT);
    } else {
        activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    }
    // 生成一个状态栏大小的矩形
    // 添加 statusBarView 到布局中
    ViewGroup contentLayout = (ViewGroup) drawerLayout.getChildAt(0);
    View fakeStatusBarView = contentLayout.findViewById(FAKE_STATUS_BAR_VIEW_ID);
    if (fakeStatusBarView != null) {
        if (fakeStatusBarView.getVisibility() == View.GONE) {
            fakeStatusBarView.setVisibility(View.VISIBLE);
        }
        fakeStatusBarView.setBackgroundColor(color);
    } else {
        contentLayout.addView(createStatusBarView(activity, color), 0);
    }
    // 内容布局不是 LinearLayout 时,设置padding top
    if (!(contentLayout instanceof LinearLayout) && contentLayout.getChildAt(1) != null) {
        contentLayout.getChildAt(1)
                .setPadding(contentLayout.getPaddingLeft(), getStatusBarHeight(activity) + contentLayout.getPaddingTop(),
                        contentLayout.getPaddingRight(), contentLayout.getPaddingBottom());
    }
    // 设置属性
    setDrawerLayoutProperty(drawerLayout, contentLayout);
    addTranslucentView(activity, statusBarAlpha);
}
 
Example 14
Source Project: Telegram   Source File: EditTextCaption.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
    super.onInitializeAccessibilityNodeInfo(info);
    if (!TextUtils.isEmpty(caption)) {
        if (Build.VERSION.SDK_INT >= 26) {
            info.setHintText(caption);
        } else {
            info.setText(info.getText() + ", " + caption);
        }
    }
}
 
Example 15
Source Project: V2EX   Source File: SystemBarTintManager.java    License: GNU General Public License v3.0 5 votes vote down vote up
@TargetApi(14)
private int getNavigationBarWidth(Context context) {
    Resources res = context.getResources();
    int result = 0;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        if (hasNavBar(context)) {
            return getInternalDimensionSize(res, NAV_BAR_WIDTH_RES_NAME);
        }
    }
    return result;
}
 
Example 16
/**
 * @brief Changes the color scheme when switching from normal mode to edit mode.
 * <p/>
 * Edit mode is triggered, when the list item is long pressed.
 */
private void changeColorScheme() {
    int primaryColor = ContextCompat.getColor(getActivity(), R.color.color_primary_dark);
    int primaryColorDark = ContextCompat.getColor(getActivity(), R.color.color_selected_dark);
    ((AppCompatActivity) activity).getSupportActionBar().setBackgroundDrawable(new ColorDrawable(primaryColor));
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        activity.getWindow().setStatusBarColor(primaryColorDark);
        activity.getWindow().setNavigationBarColor(primaryColor);
    }

    showTemplateSelectedMenu = true;
    activity.invalidateOptionsMenu();
}
 
Example 17
Source Project: Ruisi   Source File: ArrowTextView.java    License: Apache License 2.0 5 votes vote down vote up
private void drawRound(Canvas canvas, float arrowInHeight) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        canvas.drawRoundRect(0, arrowInHeight, getWidth(), getHeight(), 4, 4, paint);
        return;
    }
    RectF rectF = new RectF(0, arrowInHeight, getWidth(), getHeight());
    canvas.drawRoundRect(rectF, 4, 4, paint);
}
 
Example 18
Source Project: YalpStore   Source File: ThemeManager.java    License: GNU General Public License v2.0 5 votes vote down vote up
protected int getThemeLight() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        return android.R.style.Theme_Material_Light;
    } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        return android.R.style.Theme_Holo_Light;
    } else {
        return android.R.style.Theme_Light;
    }
}
 
Example 19
Source Project: Sensor-Data-Logger   Source File: GoogleApiMessenger.java    License: Apache License 2.0 5 votes vote down vote up
public String getNodeName(String id) {
    Node node = getLastConnectedNodeById(id);
    if (node != null) {
        return node.getDisplayName();
    } else {
        if (id == null || id.equals(DEFAULT_NODE_ID)) {
            return Build.MODEL;
        } else {
            return id;
        }
    }
}
 
Example 20
Source Project: PlayerBase   Source File: ShareAnimationActivityA.java    License: Apache License 2.0 5 votes vote down vote up
@OnClick({R.id.album_layout, R.id.tv_title})
public void onViewClicked(View view) {
    ShareAnimationPlayer.get().setReceiverGroup(mReceiverGroup);
    switch (view.getId()) {
        case R.id.album_layout:
            playIcon.setVisibility(View.GONE);
            ShareAnimationPlayer.get().play(mLayoutContainer, mData);
            break;
        case R.id.tv_title:
            toNext = true;
            Intent intent = new Intent(this, ShareAnimationActivityB.class);
            intent.putExtra(ShareAnimationActivityB.KEY_DATA, mData);
            if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.LOLLIPOP){
                ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(
                        this, mLayoutContainer, "videoShare");
                ActivityCompat.startActivity(this, intent, options.toBundle());
            }else{
                startActivity(intent);
            }
            break;
    }
}
 
Example 21
Source Project: AndroidTvDemo   Source File: TextureRenderView.java    License: Apache License 2.0 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public void bindToMediaPlayer(IMediaPlayer mp)
{
    if (mp == null)
        return;
    
    if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) && (mp instanceof ISurfaceTextureHolder))
    {
        ISurfaceTextureHolder textureHolder = (ISurfaceTextureHolder)mp;
        mTextureView.mSurfaceCallback.setOwnSurfaceTexture(false);
        
        SurfaceTexture surfaceTexture = textureHolder.getSurfaceTexture();
        if (surfaceTexture != null)
        {
            mTextureView.setSurfaceTexture(surfaceTexture);
        }
        else
        {
            textureHolder.setSurfaceTexture(mSurfaceTexture);
            textureHolder.setSurfaceTextureHost(mTextureView.mSurfaceCallback);
        }
    }
    else
    {
        mp.setSurface(openSurface());
    }
}
 
Example 22
protected void updateViewsAzimuthElevationText(Context context, RemoteViews views, SuntimesCalculator.MoonPosition moonPosition)
{
    SuntimesUtils.TimeDisplayText azimuthDisplay = utils.formatAsDirection2(moonPosition.azimuth, PositionLayout.DECIMAL_PLACES, false);
    views.setTextViewText(R.id.info_moon_azimuth_current, PositionLayout.styleAzimuthText(azimuthDisplay, highlightColor, suffixColor, boldTime));

    if (Build.VERSION.SDK_INT >= 15) {
        SuntimesUtils.TimeDisplayText azimuthDescription = utils.formatAsDirection2(moonPosition.azimuth, PositionLayout.DECIMAL_PLACES, true);
        views.setContentDescription(R.id.info_moon_azimuth_current, utils.formatAsDirection(azimuthDescription.getValue(), azimuthDescription.getSuffix()));
    }
    views.setTextViewText(R.id.info_moon_elevation_current, PositionLayout.styleElevationText(moonPosition.elevation, highlightColor, suffixColor, boldTime));
}
 
Example 23
Source Project: Jide-Note   Source File: RevealAnimator.java    License: MIT License 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
RevealFinishedIceCreamSandwich(RevealAnimator target, Rect bounds) {
    mReference = new WeakReference<>(target);
    mInvalidateBounds = bounds;

    mLayerType = ((View) target).getLayerType();
}
 
Example 24
Source Project: android-utils   Source File: ImageUtils.java    License: MIT License 5 votes vote down vote up
/**
 * Get the size of parameter {@link Bitmap}. This maybe a heavy operation.
 * Prefer not calling from main thread of the activity.
 *
 * @param data
 * @return
 */
public static int sizeOf(Bitmap data) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB_MR1) {
        return data.getRowBytes() * data.getHeight();
    } else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
        return data.getByteCount();
    } else {
        return data.getAllocationByteCount();
    }
}
 
Example 25
Source Project: timecat   Source File: ListenClipboardService.java    License: Apache License 2.0 5 votes vote down vote up
private void startGreyService() {
    if (!isGrayGuardOn) {
        if (Build.VERSION.SDK_INT < 18) {
            startForeground(GRAY_SERVICE_ID, new Notification());
        } else {
            Intent innerIntent = new Intent(ListenClipboardService.this, GrayInnerService.class);
            startService(innerIntent);
            startForeground(GRAY_SERVICE_ID, new Notification());
        }
        isGrayGuardOn = true;
    }
}
 
Example 26
Source Project: delion   Source File: PwsClientImpl.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Recreate the Chrome for Android User-Agent string as closely as possible without calling any
 * native code.
 * @return A User-Agent string
 */
@VisibleForTesting
String getUserAgent() {
    if (sUserAgent == null) {
        // Build the OS info string.
        // eg: Linux; Android 5.1.1; Nexus 4 Build/LMY48T
        String osInfo = String.format(OS_INFO_FORMAT, Build.VERSION.RELEASE, Build.MODEL,
                Build.ID);

        // Build the product string.
        // eg: Chrome/50.0.2661.89 Mobile
        String product = String.format(PRODUCT_FORMAT, ChromeVersionInfo.getProductVersion());

        // Build the User-Agent string.
        // eg: Mozilla/5.0 (Linux; Android 5.1.1; Nexus 4 Build/LMY48T) AppleWebKit/0.0 (KHTML,
        //     like Gecko) Chrome/50.0.2661.89 Mobile Safari/0.0
        sUserAgent = String.format(USER_AGENT_FORMAT, osInfo, product);
    }
    return sUserAgent;
}
 
Example 27
Source Project: Cangol-appcore   Source File: CoreApplication.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    if (DeviceInfo.isAppProcess(this)) {
        if (mStrictMode && Build.VERSION.SDK_INT >= 14) {
            StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectAll().penaltyLog().build());
            StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll().penaltyLog().build());
        }
        if (mDevMode) {
            Log.setLogLevelFormat(android.util.Log.VERBOSE, false);
        } else {
            Log.setLogLevelFormat(android.util.Log.WARN, true);
        }
        mSharePool = PoolManager.getPool("share");
        initAppServiceManager();
        mModuleManager.onCreate();
        if (mAsyncInit) {
            post(new Runnable() {
                @Override
                public void run() {
                    init();
                    mModuleManager.init();
                }
            });
        } else {
            init();
            mModuleManager.init();
        }
    } else {
        mModuleManager.onCreate();
        Log.i("cur process is not app' process");
    }
}
 
Example 28
Source Project: Locate-driver   Source File: MainActivity.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
    if(getString(R.string.settings_enable_in_ups_mode).equals(key)) {
        // Ups mode: Ultra power saving mode
        boolean shouldAppBeEnabledInUpsMode = sharedPreferences.getBoolean(key, false);
        if(shouldAppBeEnabledInUpsMode && Build.VERSION.SDK_INT >= 23) {
            requestIgnoreBatteryOptimizationsPermission();
        }
    }
}
 
Example 29
Source Project: MyBookshelf   Source File: ATH.java    License: GNU General Public License v3.0 5 votes vote down vote up
public static void setLightNavigationbar(Activity activity, boolean enabled) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        final View decorView = activity.getWindow().getDecorView();
        int systemUiVisibility = decorView.getSystemUiVisibility();
        if (enabled) {
            systemUiVisibility |= SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
        } else {
            systemUiVisibility &= ~SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
        }
        decorView.setSystemUiVisibility(systemUiVisibility);
    }
}
 
Example 30
private void showTips(int iconResId, int msgResId) {
	if (tipsToast != null) {
		if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
			tipsToast.cancel();
		}
	} else {
		tipsToast = TipsToast.makeText(context, msgResId,
				TipsToast.LENGTH_SHORT);
	}
	tipsToast.show();
	tipsToast.setIcon(iconResId);
	tipsToast.setText(msgResId);
}