Search in sources :

Example 51 with TargetApi

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);
}
Also used : Context(android.content.Context) IntentFilter(android.content.IntentFilter) Intent(android.content.Intent) BroadcastReceiver(android.content.BroadcastReceiver) TargetApi(android.annotation.TargetApi)

Example 52 with TargetApi

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);
        }
    }
}
Also used : Configuration(android.content.res.Configuration) SuppressLint(android.annotation.SuppressLint) TargetApi(android.annotation.TargetApi)

Example 53 with TargetApi

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();
            }
        }
    });
}
Also used : Button(android.widget.Button) View(android.view.View) TargetApi(android.annotation.TargetApi)

Example 54 with TargetApi

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;
}
Also used : RectF(android.graphics.RectF) Rect(android.graphics.Rect) Matrix(android.graphics.Matrix) InputStream(java.io.InputStream) BitmapRegionDecoder(android.graphics.BitmapRegionDecoder) IOException(java.io.IOException) TargetApi(android.annotation.TargetApi)

Example 55 with TargetApi

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);
}
Also used : Message(android.os.Message) StartRMData(org.altbeacon.beacon.service.StartRMData) RemoteException(android.os.RemoteException) TargetApi(android.annotation.TargetApi)

Aggregations

TargetApi (android.annotation.TargetApi)1365 Intent (android.content.Intent)153 View (android.view.View)147 Test (org.junit.Test)119 SuppressLint (android.annotation.SuppressLint)115 Uri (android.net.Uri)70 ArrayList (java.util.ArrayList)68 Animator (android.animation.Animator)67 Point (android.graphics.Point)64 Window (android.view.Window)56 TextView (android.widget.TextView)56 IOException (java.io.IOException)56 ViewGroup (android.view.ViewGroup)53 Matchers.anyString (org.mockito.Matchers.anyString)53 SharedPreferences (android.content.SharedPreferences)44 File (java.io.File)44 Field (java.lang.reflect.Field)44 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)43 Bitmap (android.graphics.Bitmap)42 ImageView (android.widget.ImageView)40