use of android.annotation.TargetApi in project AndroidChromium by JackyAndroid.
the class SupervisedUserContentProvider method createEnabledBroadcastReceiver.
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void createEnabledBroadcastReceiver() {
IntentFilter restrictionsFilter = new IntentFilter(Intent.ACTION_APPLICATION_RESTRICTIONS_CHANGED);
BroadcastReceiver restrictionsReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
updateEnabledState();
}
};
getContext().registerReceiver(restrictionsReceiver, restrictionsFilter);
}
use of android.annotation.TargetApi in project AndroidChromium by JackyAndroid.
the class AsyncInitializationActivity method attachBaseContext.
@Override
// TODO(estevenson): Replace with Build.VERSION_CODES.N when available.
@TargetApi(24)
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(newBase);
// Android will load the tab strip resources. See crbug.com/588838.
if (Build.VERSION.CODENAME.equals("N") || Build.VERSION.SDK_INT > Build.VERSION_CODES.M) {
int smallestDeviceWidthDp = DeviceFormFactor.getSmallestDeviceWidthDp(this);
if (smallestDeviceWidthDp >= DeviceFormFactor.MINIMUM_TABLET_WIDTH_DP) {
Configuration overrideConfiguration = new Configuration();
overrideConfiguration.smallestScreenWidthDp = smallestDeviceWidthDp;
applyOverrideConfiguration(overrideConfiguration);
}
}
}
use of android.annotation.TargetApi in project AndroidDevelop by 7449.
the class MainActivity method onCreate.
@TargetApi(Build.VERSION_CODES.M)
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button mFingerBtn = (Button) findViewById(R.id.finger_btn);
fingerprintManager = FingerprintManagerCompat.from(this);
keyguardManager = (KeyguardManager) this.getSystemService(Context.KEYGUARD_SERVICE);
mFingerBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (isFinger()) {
startFinger();
}
}
});
}
use of android.annotation.TargetApi in project UltimateAndroid by cymcsg.
the class CropImageActivity method decodeRegionCrop.
@TargetApi(10)
private Bitmap decodeRegionCrop(Bitmap croppedImage, Rect rect) {
// Release memory now
clearImageView();
InputStream is = null;
try {
is = getContentResolver().openInputStream(sourceUri);
BitmapRegionDecoder decoder = BitmapRegionDecoder.newInstance(is, false);
final int width = decoder.getWidth();
final int height = decoder.getHeight();
if (exifRotation != 0) {
// Adjust crop area to account for image rotation
Matrix matrix = new Matrix();
matrix.setRotate(-exifRotation);
RectF adjusted = new RectF();
matrix.mapRect(adjusted, new RectF(rect));
// Adjust to account for origin at 0,0
adjusted.offset(adjusted.left < 0 ? width : 0, adjusted.top < 0 ? height : 0);
rect = new Rect((int) adjusted.left, (int) adjusted.top, (int) adjusted.right, (int) adjusted.bottom);
}
try {
croppedImage = decoder.decodeRegion(rect, new BitmapFactory.Options());
} catch (IllegalArgumentException e) {
// Rethrow with some extra information
throw new IllegalArgumentException("Rectangle " + rect + " is outside of the image (" + width + "," + height + "," + exifRotation + ")", e);
}
} catch (IOException e) {
Logs.e("Error cropping image: " + e.getMessage(), e);
finish();
} catch (OutOfMemoryError e) {
Log.e("OOM cropping image: " + e.getMessage(), e);
setResultException(e);
} finally {
CropUtil.closeSilently(is);
}
return croppedImage;
}
use of android.annotation.TargetApi in project android-beacon-library by AltBeacon.
the class BeaconManager method updateScanPeriods.
/**
* Updates an already running scan with scanPeriod/betweenScanPeriod according to Background/Foreground state.
* Change will take effect on the start of the next scan cycle.
*
* @throws RemoteException - If the BeaconManager is not bound to the service.
*/
@TargetApi(18)
public void updateScanPeriods() throws RemoteException {
if (android.os.Build.VERSION.SDK_INT < 18) {
LogManager.w(TAG, "Not supported prior to API 18. Method invocation will be ignored");
return;
}
if (serviceMessenger == null) {
throw new RemoteException("The BeaconManager is not bound to the service. Call beaconManager.bind(BeaconConsumer consumer) and wait for a callback to onBeaconServiceConnect()");
}
Message msg = Message.obtain(null, BeaconService.MSG_SET_SCAN_PERIODS, 0, 0);
LogManager.d(TAG, "updating background flag to %s", mBackgroundMode);
LogManager.d(TAG, "updating scan period to %s, %s", this.getScanPeriod(), this.getBetweenScanPeriod());
StartRMData obj = new StartRMData(this.getScanPeriod(), this.getBetweenScanPeriod(), this.mBackgroundMode);
msg.obj = obj;
serviceMessenger.send(msg);
}
Aggregations