use of android.support.annotation.RequiresApi in project grafika by google.
the class ScreenRecordActivity method prepareVideoEncoder.
@RequiresApi(api = Build.VERSION_CODES.M)
private void prepareVideoEncoder(int width, int height) {
MediaFormat format = MediaFormat.createVideoFormat(VIDEO_MIME_TYPE, width, height);
// 30 fps
int frameRate = 30;
// Set some required properties. The media codec may fail if these aren't defined.
format.setInteger(MediaFormat.KEY_COLOR_FORMAT, MediaCodecInfo.CodecCapabilities.COLOR_FormatSurface);
// 6Mbps
format.setInteger(MediaFormat.KEY_BIT_RATE, 6000000);
format.setInteger(MediaFormat.KEY_FRAME_RATE, frameRate);
format.setInteger(MediaFormat.KEY_CAPTURE_RATE, frameRate);
format.setInteger(MediaFormat.KEY_REPEAT_PREVIOUS_FRAME_AFTER, 1000000 / frameRate);
format.setInteger(MediaFormat.KEY_CHANNEL_COUNT, 1);
// 1 seconds between I-frames
format.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, 1);
// Create a MediaCodec encoder and configure it. Get a Surface we can use for recording into.
try {
videoEncoder = MediaCodec.createEncoderByType(VIDEO_MIME_TYPE);
videoEncoder.configure(format, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE);
inputSurface = videoEncoder.createInputSurface();
videoEncoder.setCallback(encoderCallback);
videoEncoder.start();
} catch (IOException e) {
releaseEncoders();
}
}
use of android.support.annotation.RequiresApi in project SpotiQ by ZinoKader.
the class ShortcutUtil method addSearchShortcut.
@RequiresApi(api = Build.VERSION_CODES.N_MR1)
public static void addSearchShortcut(Context context, String searchWithPartyTitle) {
ShortcutManager shortcutManager = context.getSystemService(ShortcutManager.class);
Intent openSearch = new Intent(context.getApplicationContext(), SearchActivity.class);
openSearch.putExtra(ApplicationConstants.PARTY_NAME_EXTRA, searchWithPartyTitle);
openSearch.setAction(Intent.ACTION_VIEW);
ShortcutInfo shortcut = new ShortcutInfo.Builder(context, ApplicationConstants.SEARCH_SHORTCUT_ID).setShortLabel("Search songs").setLongLabel("Search for songs to add to the queue").setIcon(Icon.createWithResource(context, R.drawable.ic_shortcut_search)).setIntent(openSearch).build();
shortcutManager.setDynamicShortcuts(Arrays.asList(shortcut));
}
use of android.support.annotation.RequiresApi in project TumCampusApp by TCA-Team.
the class SilenceService method requestPermissionsSDK23.
@RequiresApi(Build.VERSION_CODES.M)
private static void requestPermissionsSDK23(Context context) {
Intent intent = new Intent(Settings.ACTION_NOTIFICATION_POLICY_ACCESS_SETTINGS);
context.startActivity(intent);
}
use of android.support.annotation.RequiresApi in project glide by bumptech.
the class RequestManagerRetrieverTest method testDoesNotThrowIfAskedToGetManagerForActivityPreJellYBeanMr1.
@Test
@RequiresApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public void testDoesNotThrowIfAskedToGetManagerForActivityPreJellYBeanMr1() {
Util.setSdkVersionInt(Build.VERSION_CODES.JELLY_BEAN);
Activity activity = Robolectric.buildActivity(Activity.class).create().start().resume().get();
Activity spyActivity = Mockito.spy(activity);
when(spyActivity.isDestroyed()).thenThrow(new NoSuchMethodError());
assertNotNull(retriever.get(spyActivity));
}
use of android.support.annotation.RequiresApi in project focus-android by mozilla-mobile.
the class TextActionActivity method onCreate.
@RequiresApi(api = Build.VERSION_CODES.M)
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final SafeIntent intent = new SafeIntent(getIntent());
final CharSequence searchTextCharSequence = intent.getCharSequenceExtra(Intent.EXTRA_PROCESS_TEXT);
final String searchText;
if (searchTextCharSequence != null) {
searchText = searchTextCharSequence.toString();
} else {
searchText = "";
}
final String searchUrl = UrlUtils.createSearchUrl(this, searchText);
final Intent searchIntent = new Intent(this, MainActivity.class);
searchIntent.setAction(Intent.ACTION_VIEW);
searchIntent.putExtra(MainActivity.EXTRA_TEXT_SELECTION, true);
searchIntent.setData(Uri.parse(searchUrl));
startActivity(searchIntent);
finish();
}
Aggregations