当前位置: 首页>>代码示例>>Java>>正文


Java Build类代码示例

本文整理汇总了Java中android.os.Build的典型用法代码示例。如果您正苦于以下问题:Java Build类的具体用法?Java Build怎么用?Java Build使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Build类属于android.os包,在下文中一共展示了Build类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1:

import android.os.Build; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR1)
public void onChildViewAdded(View parent, View child) {
    if (parent == RelativeRadioGroup.this && child instanceof RadioButton) {
        int id = child.getId();
        // generates an id if it's missing
        if (id == View.NO_ID) {
            id = View.generateViewId();
            child.setId(id);
        }
        ((RadioButton) child).setOnCheckedChangeListener(mChildOnCheckedChangeListener);
    }

    if (mOnHierarchyChangeListener != null) {
        mOnHierarchyChangeListener.onChildViewAdded(parent, child);
    }
}
 
开发者ID:mmb4rn0,项目名称:RelativeRadioGroup,代码行数:20,代码来源:RelativeRadioGroup.java

示例2: postOnAnimation

import android.os.Build; //导入依赖的package包/类
private void postOnAnimation(View view, Runnable runnable) {
    if (Build.VERSION.SDK_INT >= 16) {
        view.postOnAnimation(runnable);
    } else {
        view.postDelayed(runnable, 16L);
    }
}
 
开发者ID:lanyuanxiaoyao,项目名称:PicKing,代码行数:8,代码来源:Attacher.java

示例3: finishActivitySync

import android.os.Build; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
static public void finishActivitySync(Activity activity, Instrumentation instrumentation, boolean doFinish)
{
    if (doFinish)
        activity.finish();
    //give activity one minute to finish
    long currentTime = System.currentTimeMillis();
    boolean finishTimeout = false;
    int activityHash = activity.hashCode();
    boolean isDestroyed = false;

    while (!isDestroyed && !finishTimeout) {
        instrumentation.waitForIdleSync();
        finishTimeout = (System.currentTimeMillis() - currentTime) > 140000;

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
            isDestroyed = activity.isDestroyed();
        }else {
            isDestroyed = (Boolean)callMethod(null, activity.getWindow(), "isDestroyed", null);
        }
    }

    if (finishTimeout) {
        WebtrekkLogging.log("finishActivitySync: finished by timeout. Hash:" + activityHash);
    }
}
 
开发者ID:Webtrekk,项目名称:webtrekk-android-sdk,代码行数:27,代码来源:WebtrekkBaseSDKTest.java

示例4: init

import android.os.Build; //导入依赖的package包/类
private void init(Context context) {
	if (notification_panel_width == 0) {
		Context systemUi = null;
		try {
			systemUi = context.createPackageContext("com.android.systemui", Context.CONTEXT_IGNORE_SECURITY);
		} catch (PackageManager.NameNotFoundException e) {
		}
		if (Build.VERSION.SDK_INT <= 19) {
			notification_side_padding = 0;
		} else {
			notification_side_padding = getDimem(context, systemUi, "notification_side_padding",
					R.dimen.notification_side_padding);
		}
		notification_panel_width = getDimem(context, systemUi, "notification_panel_width",
				R.dimen.notification_panel_width);
		if (notification_panel_width <= 0) {
			notification_panel_width = context.getResources().getDisplayMetrics().widthPixels;
		}
		notification_min_height = getDimem(context, systemUi, "notification_min_height",
				R.dimen.notification_min_height);
		// getDimem(context, systemUi, "notification_row_min_height", 0);
		// if (notification_min_height == 0) {
		// notification_min_height =
		// }
		notification_max_height = getDimem(context, systemUi, "notification_max_height",
				R.dimen.notification_max_height);
		notification_mid_height = getDimem(context, systemUi, "notification_mid_height",
				R.dimen.notification_mid_height);
		notification_padding = getDimem(context, systemUi, "notification_padding", R.dimen.notification_padding);
		// notification_collapse_second_card_padding
	}
}
 
开发者ID:codehz,项目名称:container,代码行数:33,代码来源:RemoteViewsUtils.java

示例5: newInstance

import android.os.Build; //导入依赖的package包/类
public static GestureDetector newInstance(Context context,
                                          OnGestureListener listener) {
    final int sdkVersion = Build.VERSION.SDK_INT;
    GestureDetector detector;

    if (sdkVersion < Build.VERSION_CODES.ECLAIR) {
        detector = new CupcakeGestureDetector(context);
    } else if (sdkVersion < Build.VERSION_CODES.FROYO) {
        detector = new EclairGestureDetector(context);
    } else {
        detector = new FroyoGestureDetector(context);
    }

    detector.setOnGestureListener(listener);

    return detector;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:VersionedGestureDetector.java

示例6:

import android.os.Build; //导入依赖的package包/类
@RequiresApi(api = Build.VERSION_CODES.M)
@Override
public void onRequestPermissionsResult(int requestCode,
                                       @NonNull String[] permissions,
                                       @NonNull int[] grantResults) {

    if (grantResults.length != 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
        if (requestCode == RC_HANDLE_WRITE_PERM) {
            callPickPhoto();
        } else if (requestCode == RC_CAMERA_PERM) {

            int rc = ActivityCompat.checkSelfPermission(mContext, Manifest.permission.WRITE_EXTERNAL_STORAGE);
            if (rc == PackageManager.PERMISSION_GRANTED) {
                callCamera();
            } else {
                requestWriteExternalStoragePermission(RC_CAMERA_PERM);
            }
        }
    }
}
 
开发者ID:victoraldir,项目名称:BuddyBook,代码行数:21,代码来源:InsertEditBookActivity.java

示例7: getSDCardSize

import android.os.Build; //导入依赖的package包/类
/**
 * 获取SD卡全部内存空间大小
 *
 * @return
 */
public static long getSDCardSize() {
    long blockCount;
    long blockSize;

    if (isSDCardMounted()) {
        String dir = getSDCardBaseDir();
        //StatFs是从C语言引过来的
        StatFs statFs = new StatFs(dir);

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
            blockCount = statFs.getBlockCountLong();//有多少块
            blockSize = statFs.getBlockSizeLong();//每块有多大
        } else {
            blockCount = statFs.getBlockCount();//有多少块
            blockSize = statFs.getBlockSize();//每块有多大
        }

        return blockCount * blockSize / 1024 / 1024; //总大小
    }
    return 0;
}
 
开发者ID:CodingCodersCode,项目名称:EvolvingNetLib,代码行数:27,代码来源:SDCardUtil.java

示例8: queryIntentActivities

import android.os.Build; //导入依赖的package包/类
@Override
public List<ResolveInfo> queryIntentActivities(Intent intent, String resolvedType, int flags, int userId) {
    checkUserId(userId);
    flags = updateFlagsNought(flags);
    ComponentName comp = intent.getComponent();
    if (comp == null) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
            if (intent.getSelector() != null) {
                intent = intent.getSelector();
                comp = intent.getComponent();
            }
        }
    }
    if (comp != null) {
        final List<ResolveInfo> list = new ArrayList<ResolveInfo>(1);
        final ActivityInfo ai = getActivityInfo(comp, flags, userId);
        if (ai != null) {
            final ResolveInfo ri = new ResolveInfo();
            ri.activityInfo = ai;
            list.add(ri);
        }
        return list;
    }

    // reader
    synchronized (mPackages) {
        final String pkgName = intent.getPackage();
        if (pkgName == null) {
            return mActivities.queryIntent(intent, resolvedType, flags, userId);
        }
        final VPackage pkg = mPackages.get(pkgName);
        if (pkg != null) {
            return mActivities.queryIntentForPackage(intent, resolvedType, flags, pkg.activities, userId);
        }
        return Collections.emptyList();
    }
}
 
开发者ID:7763sea,项目名称:VirtualHook,代码行数:38,代码来源:VPackageManagerService.java

示例9: onRequestPermissionsResult

import android.os.Build; //导入依赖的package包/类
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
    if (requestCode == AUDIO_PERMISSION_REQUEST && permissions[0]
            .equals(android.Manifest.permission.RECORD_AUDIO)) {
        if (grantResults[0] == PackageManager.PERMISSION_DENIED) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                boolean showAgain =
                        shouldShowRequestPermissionRationale
                                (android.Manifest.permission.RECORD_AUDIO);
                if (showAgain) {

                }
            }
            finish(); // can't use audio
        }
    } else
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
 
开发者ID:gvsucis,项目名称:mobile-app-dev-book,代码行数:19,代码来源:AudioActivity.java

示例10: getExternalFilesDirs

import android.os.Build; //导入依赖的package包/类
public static File[] getExternalFilesDirs(Context context, String type) {
    final int version = Build.VERSION.SDK_INT;
    if (version >= 19) {
        //返回结果可能存在null值
        return context.getExternalFilesDirs(type);
    } else {
        return new File[] { context.getExternalFilesDir(type) };
    }
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:10,代码来源:Framework.java

示例11:

import android.os.Build; //导入依赖的package包/类
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
void dispatchOnCancelled(LoadTask task, D data) {
    onCanceled(data);
    if (mCancellingTask == task) {
        if (DEBUG) Log.v(TAG, "Cancelled task is now canceled!");
        if(Utils.hasJellyBeanMR2()){
        	rollbackContentChanged();
        }
        mLastLoadCompleteTime = SystemClock.uptimeMillis();
        mCancellingTask = null;
        if (DEBUG) Log.v(TAG, "Delivering cancellation");
        if(Utils.hasJellyBeanMR2()){
        	deliverCancellation();
        }
        executePendingTask();
    }
}
 
开发者ID:medalionk,项目名称:simple-share-android,代码行数:18,代码来源:AsyncTaskLoader.java

示例12: animateIn

import android.os.Build; //导入依赖的package包/类
private void animateIn(FloatingActionButton button) {
    button.setVisibility(View.VISIBLE);
    if (Build.VERSION.SDK_INT >= 14) {
        ViewCompat.animate(button)
            .scaleX(1.0F)
            .scaleY(1.0F)
            .alpha(1.0F)
            .setInterpolator(INTERPOLATOR)
            .withLayer()
            .setListener(null)
            .start();
    } else {
        Animation anim = AnimationUtils.loadAnimation(button.getContext(),
            android.support.design.R.anim.design_fab_in);
        anim.setDuration(200L);
        anim.setInterpolator(INTERPOLATOR);
        button.startAnimation(anim);
    }
}
 
开发者ID:drakeet,项目名称:rebase-android,代码行数:20,代码来源:ScrollAwareFABBehavior.java

示例13: build

import android.os.Build; //导入依赖的package包/类
public final T build() {
    for (Integer minVersion : implementations.keySet()) {
        if (Build.VERSION.SDK_INT >= minVersion) {
            String className = implementations.get(minVersion);
            try {
                Class<? extends T> clazz = Class.forName(className).asSubclass(managedInterface);
                Log.i(TAG, "Using implementation " + clazz + " of " + managedInterface + " for SDK " + minVersion);
                return clazz.getConstructor().newInstance();
            } catch (ClassNotFoundException cnfe) {
                Log.w(TAG, cnfe);
            } catch (IllegalAccessException iae) {
                Log.w(TAG, iae);
            } catch (InstantiationException ie) {
                Log.w(TAG, ie);
            } catch (NoSuchMethodException nsme) {
                Log.w(TAG, nsme);
            } catch (InvocationTargetException ite) {
                Log.w(TAG, ite);
            }
        }
    }
    Log.i(TAG, "Using default implementation " + defaultImplementation.getClass() + " of " + managedInterface);
    return defaultImplementation;
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:25,代码来源:PlatformSupportManager.java

示例14: collectCrashDeviceInfo

import android.os.Build; //导入依赖的package包/类
public void collectCrashDeviceInfo(Context ctx) {
    try {
        PackageInfo pi = ctx.getPackageManager().getPackageInfo(ctx.getPackageName(), 1);
        if (pi != null) {
            this.mDeviceCrashInfo.put(VERSION_NAME, pi.versionName == null ? "not set" : pi.versionName);
            this.mDeviceCrashInfo.put(VERSION_CODE, pi.versionCode + "");
        }
    } catch (NameNotFoundException e) {
        LogInfo.log(TAG, "Error while collect package info" + e);
    }
    for (Field field : Build.class.getDeclaredFields()) {
        try {
            field.setAccessible(true);
            this.mDeviceCrashInfo.put(field.getName(), field.get(null).toString());
            LogInfo.log(TAG, field.getName() + " : " + field.get(null));
        } catch (Exception e2) {
            LogInfo.log(TAG, "Error while collect crash info" + e2);
        }
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:21,代码来源:CrashHandler.java

示例15: getApplicationInfo

import android.os.Build; //导入依赖的package包/类
private ApplicationInfo getApplicationInfo(Notification notification) {
    ApplicationInfo ai = getApplicationInfo(notification.tickerView);
    if (ai != null) {
        return ai;
    }
    ai = getApplicationInfo(notification.contentView);
    if (ai != null) {
        return ai;
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        ai = getApplicationInfo(notification.bigContentView);
        if (ai != null) {
            return ai;
        }
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        ai = getApplicationInfo(notification.headsUpContentView);
        if (ai != null) {
            return ai;
        }
    }
    return null;
}
 
开发者ID:coding-dream,项目名称:TPlayer,代码行数:24,代码来源:NotificationCompatCompatV21.java


注:本文中的android.os.Build类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。