Skip to content

Instantly share code, notes, and snippets.

View HBiSoft's full-sized avatar

Hagen Brooks HBiSoft

  • Cape Town, South Africa.
View GitHub Profile
@HBiSoft
HBiSoft / SupportedMediaCodecInstances.java
Last active December 8, 2020 15:39
Get number of concurrent MediaCodec instances
/*
*
* This will return the number of `MediaCodec` instances a device can run
* at the same time with the given dimensions and mime type.
*
* This will only work on API 21>
*
* It keeps creating instances until Error 0xffffec77 is called
* It then returns the number of instances that was successfully created
*
@HBiSoft
HBiSoft / FileUtils.java
Last active February 1, 2024 19:10
This fixes the issue when selecting a file from Downloads directory as well as the SD Card. This class can be called like this: String sourcePath = FileUtils.getRealPathFromURI_API19(this, data.getData());
import android.annotation.SuppressLint;
import android.content.ContentUris;
import android.content.Context;
import android.content.CursorLoader;
import android.database.Cursor;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;
import android.provider.DocumentsContract;
import android.provider.MediaStore;