native - FileDescriptor's actual system file descriptor (as int) in Android -


What is the file descriptor object from Android that can get system file descriptor (as socket or file number as int)? I want to access the file descriptor directly in JNI code without using any Java wrapper

Edit:. I have found getParcelFileDescriptorFD and the file descriptor is the use of the "descriptor" name in the field "example", example /jni/android_media_MediaPlayer.cpp , function definition frameworks / base / core / jnI / android_util_Binder.cpp < / Code>, the field is only in libcore / luni / src / main / java / java/io/FileDescriptor.java

but this official document is not part of the API . Is there a document "correct" way to do this?

local code in Dalvik / libcore / jniGetFDFromFileDescriptor Java_io_fileDescriptor.c , but you should not call it yourself because this is not a static API You can copy & amp; Paste that code, but before you do this, you really want to think twice. Using JNI to use the implementation details is just begging for your code in the future!

Better options are:

  1. Keep on I / O if you can, Java side.

  2. If you have to do I / O on the local side (in the case of a media player) keep open the I / O at the country side (2 ) Or whatever is on the side, instead of messing with a file descriptor object, place the FD as an integer, and if you pass anything back, you pass int or your object (this is your original Except for going back to the code, nothing is being used).

These two options work today, and can not be broken by mistake changes, you have no control over the implementation details of Android.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -