Ok this might be long post as I have spent the last 3 days (18 hrs) on this. I created a custom keyboard ext for iOS and was tasked to do the same for Android. I have everything working like I want giving the user keyboards to use that are interchangeable between letters and numbers/symbols. As well as a recycler view for custom emoji categories across the top of the keyboard. On selection of one of the categories (according to which was selected) a horizontal recycler view of the images is displayed. On selection of one of these images it should send the image to where the user wants.
This works for Facebook, Twitter, Hipchat, Google drive and keep, FB Messagener, however with mms and gmail I am given the error, unable to attach photo.
I have a custom content provider class using a ParcelFileDescriptor with a data pipe,
public class ***ContentProvider extends ContentProvider {
@Override
public ParcelFileDescriptor openFile(Uri uri, String mode) throws FileNotFoundException {
ParcelFileDescriptor[] pipe = null;
try {
pipe = ParcelFileDescriptor.createPipe();
AssetManager assests = getContext().getResources().getAssets();
new TransferThread(assests.open(uri.getLastPathSegment()), new ParcelFileDescriptor.AutoCloseOutputStream(pipe[1])).start();
} catch (IOException e) {
e.printStackTrace();
}
return pipe[0];
}
There was a thread on here that stated that the MMS looks for a Cursor with the columns "Images.Media.DATA" and "Images.Media.MIME_TYPE" before calling the openFile of the content provider. I do not have a SQLite db created so I create a matrixCursor and return it here:
@Override
public Cursor query( Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder, CancellationSignal cancellationSignal )
{
String[] columns = new String[] {"Images.Media.DATA", "Images.Media.MIME_TYPE"};
MatrixCursor matrixCursor = new MatrixCursor(columns);
matrixCursor.addRow(new Object[] {uri.getLastPathSegment(), "image/png"});
// return matrixCursor;
// TODO: Implement this method
return super.query( uri, projection, selection, selectionArgs, sortOrder, cancellationSignal );
}
except it causes the MMS application to force close.
My sharing intent code is here:
@Override
public void emojiSelection(String emojiID) {
Uri theUri = Uri.parse("content://com.***.***.***/"+emojiID);
//Sharing intent code
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("image/png");
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
//Add data to intent
intent.putExtra(Intent.EXTRA_STREAM, theUri);
Intent intent2 = Intent.createChooser(intent, "Share using...");
intent2.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent2);
}
I have the provider tags in my manifest, with read permissions and exported set to true
