what is the use of MemoryFile in android
If you want some cross-process use with MemoryFile
you can use the following fugly method:
import android.os.MemoryFile;
import android.os.ParcelFileDescriptor;
import java.io.FileDescriptor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public class MemoryFileUtil {
private static final Method sMethodGetParcelFileDescriptor;
private static final Method sMethodGetFileDescriptor;
static {
sMethodGetParcelFileDescriptor = get("getParcelFileDescriptor");
sMethodGetFileDescriptor = get("getFileDescriptor");
}
public static ParcelFileDescriptor getParcelFileDescriptor(MemoryFile file) {
try {
return (ParcelFileDescriptor) sMethodGetParcelFileDescriptor.invoke(file);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
} catch (InvocationTargetException e) {
throw new RuntimeException(e);
}
}
public static FileDescriptor getFileDescriptor(MemoryFile file) {
try {
return (FileDescriptor) sMethodGetFileDescriptor.invoke(file);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
} catch (InvocationTargetException e) {
throw new RuntimeException(e);
}
}
private static Method get(String name) {
try {
return MemoryFile.class.getDeclaredMethod(name);
} catch (NoSuchMethodException e) {
throw new RuntimeException(e);
}
}
}
What you should be looking at is the #getParcelFileDescriptor(MemoryFile)
method which you can return from an implementation of ContentProvider#openFile(Uri, String)
.
Regarding the use of Asynchronous shared memory (ASHMEM) in android apps written in java
read about MemoryFile, see this doc page http://developer.android.com/reference/android/os/MemoryFile.html
Related Topics
Urlconnection Getcontentlength() Is Returning a Negative Value
Efficiency of Searching Using Wherearraycontains
Why Does Bitmapfactory.Decodebytearray Return Null
How to Update One Field from All Documents Using Pojo in Firestore
I Cant See Any Firebaserecycleradapter Items on My Layout
Connectiontimeout Versus Sockettimeout
What Is the Simplest Way to Reverse an Arraylist
Android: How to Hide Actionbar on Certain Activities
Passing Function as a Parameter in Java
How to Delete Files Programmatically on Android
Is Dalvik's Memory Model the Same as Java'S
Method Called After Release() Exception Unable to Resume with Android Camera
Libavcodec.So: Has Text Relocations
Java: Literal Percent Sign in Printf Statement
What's the Equivalent of Java's Thread.Sleep() in JavaScript