本文整理匯總了Java中android.support.annotation.RequiresApi類的典型用法代碼示例。如果您正苦於以下問題:Java RequiresApi類的具體用法?Java RequiresApi怎麽用?Java RequiresApi使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
RequiresApi類屬於android.support.annotation包,在下文中一共展示了RequiresApi類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onChildViewAdded
import android.support.annotation.RequiresApi; //導入依賴的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);
}
}
示例2: seven
import android.support.annotation.RequiresApi; //導入依賴的package包/類
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR1)
public Bitmap seven(Context context, Bitmap bitmap){
renderScript=RenderScript.create(context);
outBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), bitmap.getConfig());
inputAllocation=Allocation.createFromBitmap(renderScript,bitmap);
outputAllocation=Allocation.createTyped(renderScript,inputAllocation.getType());
final ScriptIntrinsicColorMatrix colorMatrix7 = ScriptIntrinsicColorMatrix.create(renderScript, Element.U8_4(renderScript));
colorMatrix7.setColorMatrix(new android.renderscript.Matrix4f(new float[]
{
1.22994596833595f, 0.0209523774645382f, 0.383244054685119f, 0f,
0.450138899443543f, 1.18737418804171f, -0.106933249401007f, 0f
- 0.340084867779496f, 0.131673434493755f, 1.06368919471589f, 0f,
0f, 0f, 0f,
11.91f, 11.91f, 11.91f, 0f}));
colorMatrix7.forEach(inputAllocation, outputAllocation);
outputAllocation.copyTo(outBitmap);
return outBitmap;
}
示例3: init
import android.support.annotation.RequiresApi; //導入依賴的package包/類
@RequiresApi(api = Build.VERSION_CODES.GINGERBREAD_MR1)
@Override
public Point init(Context context, Uri uri) throws Exception {
Log.w(TAG, "Init!");
if (!PartAuthority.isLocalUri(uri)) {
passthrough = new SkiaImageRegionDecoder();
return passthrough.init(context, uri);
}
MasterSecret masterSecret = KeyCachingService.getMasterSecret(context);
if (masterSecret == null) {
throw new IllegalStateException("No master secret available...");
}
InputStream inputStream = PartAuthority.getAttachmentStream(context, masterSecret, uri);
this.bitmapRegionDecoder = BitmapRegionDecoder.newInstance(inputStream, false);
inputStream.close();
return new Point(bitmapRegionDecoder.getWidth(), bitmapRegionDecoder.getHeight());
}
示例4: createNotificationChannel
import android.support.annotation.RequiresApi; //導入依賴的package包/類
@RequiresApi(Build.VERSION_CODES.O)
private String createNotificationChannel(){
String channelId = "VBrowserNotification";
String channelName = "前台下載通知";
NotificationChannel chan = new NotificationChannel(channelId,
channelName, NotificationManager.IMPORTANCE_HIGH);
chan.setLightColor(Color.BLUE);
chan.setImportance(NotificationManager.IMPORTANCE_NONE);
chan.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);
NotificationManager service = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
service.createNotificationChannel(chan);
return channelId;
}
示例5: setAlarm
import android.support.annotation.RequiresApi; //導入依賴的package包/類
@RequiresApi(api = Build.VERSION_CODES.N)
public static void setAlarm(Context context,int hour, int minute, int second) {
Calendar calendar = Calendar.getInstance();
Calendar rightNow = Calendar.getInstance();
calendar.set(Calendar.HOUR, hour);
int timeOffset = hour - calendar.get(Calendar.HOUR);
calendar.setTimeInMillis(System.currentTimeMillis());
calendar.set(Calendar.HOUR, hour - timeOffset);
calendar.set(Calendar.MINUTE, minute);
calendar.set(Calendar.SECOND, second);
Intent intent = new Intent(context, AlarmReceiver.class);
pendingIntent = PendingIntent.getBroadcast(context, 0, intent, 0);
alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
//set the alarm repeat one day
alarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP,
calendar.getTimeInMillis(), AlarmManager.INTERVAL_DAY, pendingIntent);
Log.i("setting", String.valueOf(calendar.getTime()));
Log.i("actual", String.valueOf(rightNow.getTime()));
}
示例6: setupFingerprintStuff
import android.support.annotation.RequiresApi; //導入依賴的package包/類
@RequiresApi(api = Build.VERSION_CODES.M)
public void setupFingerprintStuff() {
fingerprintManager = (FingerprintManager) this.getSystemService(Context.FINGERPRINT_SERVICE);
fingerprintHelper = new FingerprintHelper(this);
try {
generateKey();
if (cipherInit()) {
cryptoObject = new FingerprintManager.CryptoObject(cipher);
fingerprintHelper.startAuth(fingerprintManager, cryptoObject);
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
示例7: onActivityResult
import android.support.annotation.RequiresApi; //導入依賴的package包/類
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
//PDF
if (resultCode == RESULT_OK) {
if (requestCode == SELECT_PDF) {
Uri selectedUri_PDF = data.getData();
InputStream inputstream;
try {
inputstream = getContentResolver().openInputStream(selectedUri_PDF);
pdfview.fromStream(inputstream).load();
} catch (FileNotFoundException e) {
e.printStackTrace();
Toast.makeText(PdfView.this, "unable to open", Toast.LENGTH_SHORT).show();
}
}
}
else
{
startActivity(new Intent(PdfView.this,Subjects.class));
finish();
}
}
示例8: createRippleDrawable
import android.support.annotation.RequiresApi; //導入依賴的package包/類
/**
* Creates a new {@link RippleDrawable} introduced in Lollipop.
*
* @param normalColor Color for the idle/normal state
* @param rippleColor Color for the ripple effect
* @param bounds Clipping bounds for the ripple state. Set to {@code null} to get a borderless ripple
* @param cornerRadius Set to round the corners on rectangular drawables, 0 to disable
* @return A fully colored RippleDrawable, new instance each time
*/
@NonNull
@RequiresApi(Build.VERSION_CODES.LOLLIPOP)
public static RippleDrawable createRippleDrawable(@ColorInt final int normalColor, @ColorInt final int rippleColor, @Nullable final Rect bounds,
@IntRange(from = 0) final int cornerRadius) {
Drawable maskDrawable = null;
if (bounds != null) {
// clip color is white
maskDrawable = createColoredDrawable(Color.WHITE, bounds);
if (maskDrawable instanceof GradientDrawable) {
((GradientDrawable) maskDrawable).setCornerRadius(cornerRadius);
}
maskDrawable.setBounds(bounds);
}
Drawable normalStateDrawable = null;
// transparent has no idle state
if (normalColor != Color.TRANSPARENT) {
normalStateDrawable = createColoredDrawable(normalColor, bounds);
if (normalStateDrawable instanceof GradientDrawable) {
((GradientDrawable) normalStateDrawable).setCornerRadius(cornerRadius);
}
}
return new RippleDrawable(ColorStateList.valueOf(rippleColor), normalStateDrawable, maskDrawable);
}
示例9: onCreate
import android.support.annotation.RequiresApi; //導入依賴的package包/類
@RequiresApi(api = Build.VERSION_CODES.M)
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_trips_list);
initializeToolbar();
ivHero1 = (ImageView) findViewById(R.id.iv_hero_1);
trip1Layout = (ViewGroup) findViewById(R.id.trip_1_layout);
trip1Layout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Pair<View, String> p1 = Pair.create((View) ivHero1, ivHero1.getTransitionName());
ActivityOptionsCompat options = ActivityOptionsCompat.
makeSceneTransitionAnimation((TripListActivity.this), p1);
Bundle bundle = options.toBundle();
Intent i = new Intent(TripListActivity.this, TripDetailActivity.class);
startActivity(i, bundle);
}
});
}
示例10: handleMessage
import android.support.annotation.RequiresApi; //導入依賴的package包/類
@RequiresApi(api = Build.VERSION_CODES.GINGERBREAD)
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
TextView mAuthCode = mTextViewRef.get();
if (mAuthCode == null) {
return;
}
if (!mAuthCode.getText().toString().isEmpty()) return;
switch (msg.what) {
case ReadSmsService.OBSERVER_SMS_CODE_MSG:
mAuthCode.setText((String) msg.obj);
break;
case ReadSmsService.RECEIVER_SMS_CODE_MSG:
mAuthCode.setText((String) msg.obj);
break;
default:
break;
}
recycle();
}
示例11: decodeRegion
import android.support.annotation.RequiresApi; //導入依賴的package包/類
@RequiresApi(api = Build.VERSION_CODES.GINGERBREAD_MR1)
@Override
public Bitmap decodeRegion(Rect rect, int sampleSize) {
Log.w(TAG, "Decode region: " + rect);
if (passthrough != null) {
return passthrough.decodeRegion(rect, sampleSize);
}
synchronized(this) {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = sampleSize;
options.inPreferredConfig = Bitmap.Config.RGB_565;
Bitmap bitmap = bitmapRegionDecoder.decodeRegion(rect, options);
if (bitmap == null) {
throw new RuntimeException("Skia image decoder returned null bitmap - image format may not be supported");
}
return bitmap;
}
}
示例12: fifteen
import android.support.annotation.RequiresApi; //導入依賴的package包/類
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR1)
public Bitmap fifteen(Context context, Bitmap bitmap){
renderScript=RenderScript.create(context);
outBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), bitmap.getConfig());
inputAllocation=Allocation.createFromBitmap(renderScript,bitmap);
outputAllocation=Allocation.createTyped(renderScript,inputAllocation.getType());
final ScriptIntrinsicColorMatrix colorMatrix13 = ScriptIntrinsicColorMatrix.create(renderScript, Element.U8_4(renderScript));
colorMatrix13.setColorMatrix(new android.renderscript.Matrix4f(new float[]
{
2.10279132254252f, -0.298212630531356f, 0.42128146417712f, 0f,
0.222897572029231f, 1.68701190285368f, -0.883421304780577f, 0f,
-0.765688894571747f, 0.171200727677677f, 2.02213984060346f, 0f,
0 , 0 ,0 ,1f
}));
colorMatrix13.forEach(inputAllocation, outputAllocation);
outputAllocation.copyTo(outBitmap);
return outBitmap;
}
示例13: twelve
import android.support.annotation.RequiresApi; //導入依賴的package包/類
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR1)
public Bitmap twelve(Context context, Bitmap bitmap){
renderScript=RenderScript.create(context);
outBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), bitmap.getConfig());
inputAllocation=Allocation.createFromBitmap(renderScript,bitmap);
outputAllocation=Allocation.createTyped(renderScript,inputAllocation.getType());
final ScriptIntrinsicColorMatrix colorMatrix12 = ScriptIntrinsicColorMatrix.create(renderScript, Element.U8_4(renderScript));
colorMatrix12.setColorMatrix(new android.renderscript.Matrix4f(new float[]
{
.309f, .409f, .309f, 0f,
.609f, .309f, .409f, 0f,
0.42f, .42f, .2f, 0f,
0f, 0f, 0f, 1f
}));
colorMatrix12.forEach(inputAllocation, outputAllocation);
outputAllocation.copyTo(outBitmap);
return outBitmap;
}
示例14: onCreate
import android.support.annotation.RequiresApi; //導入依賴的package包/類
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR1)
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_gallery);
parentLayout = (LinearLayout) findViewById(R.id.parent_view);
ivHeroImage = (ImageView) findViewById(R.id.iv_image_gallery);
ivClose = (ImageView) findViewById(R.id.iv_close);
imageResource = getIntent().getIntExtra("image", R.drawable.img_city_1);
ivHeroImage.setImageResource(imageResource);
ivClose.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
onBackPressed();
}
});
}
示例15: onActivityResult
import android.support.annotation.RequiresApi; //導入依賴的package包/類
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode != REQUEST_CODE) {
return;
}
if (manager == null) {
return;
}
mediaProjection = manager.getMediaProjection(resultCode, data);
if (mediaProjection == null) {
return;
}
onStartRecord();
}