jjzjj

FileDescriptor

全部标签

android - 从 sd 卡创建一个 drawable 以在 android 中设置为背景

我正在尝试使用SD卡中的图像并将其设置为相关布局的背景。我尝试了在这里和其他地方找到的其他解决方案,但它们似乎对我不起作用。这是我的代码。我已经评论了我尝试过但没有用的其他方法。唯一对我有用的是使用setBackgroudnResource并使用应用程序中的资源,但这只是为了测试以确保mRoot设置正确。当我尝试了所有其他方法时,它只是没有设置任何东西。任何人都知道我做错了什么,或者是否有更好的方法来做到这一点?//onewayitired...//StringextDir=Environment.getExternalStorageDirectory().toString();//D

android - 连接到 LocalServerSocket 时出现 EMFILE(打开的文件过多)错误?

我的应用非常简单。客户端将连接到LocalServerSocket(Unix域套接字)并发送一些数据并断开连接。如果这个过程重复超过1024次,服务器在接受新客户端时抛出java.io.IOException:socketfailed:EMFILE(Toomanyopenfiles)。我已经在这里上传了我的演示代码http://speedy.sh/NBSjr/SocketIssue.zip您可以在代码中看到客户端在与服务器建立另一个连接之前关闭了建立的连接。在logcat中,您可以看到服务器中的FileDescriptor计数在增加,并在客户端第1023次连接时崩溃。如何解决这个问题?

android - 如何在 Android 中使用 JNI 将 Assets FileDescriptor 正确传递给 FFmpeg

我正在尝试使用FFmpeg、JNI和Java在Android中检索元数据FileDescriptor而且它不起作用。我知道FFmpeg支持pipeprotocol所以我试图以编程方式模拟:“cattest.mp3|ffmpegipipe:0”。我使用以下代码从与Android应用程序bundle在一起的Assets中获取FileDescriptor:FileDescriptorfd=getContext().getAssets().openFd("test.mp3").getFileDescriptor();setDataSource(fd,0,0x7ffffffffffffffL);

android - NewFromFD 在 nativeDecodeFileDescriptor 中失败 - Android 4.4

我使用Android示例项目ContactsList(http://developer.android.com/shareables/training/ContactsList.zip)作为示例在我的应用程序中开发联系人Activity。它在所有Android版本上都能完美运行,但在Android4.4中,联系人图像未加载,我收到以下错误:NewFromFDfailedinnativeDecodeFileDescriptor在执行此方法时会发生这种情况:BitmapFactory.decodeFileDescriptor(fileDescriptor,null,options);它总是

android - 如何将 FileDescriptor 与 HTTP URL 一起使用

我希望这能够让Android的MediaPlayer使用身份验证从URL流式传输,但现在我不太确定。我没有问题让它从开放服务器流式传输(无身份验证),但我看不到任何方式告诉MediaPlayer使用基本身份验证,除非可能使用FileDescriptor争论有效吗?所以我尝试了这个但得到了以下错误:IllegalArgumentException:ExpectedfileschemeinURIhttp://www.myserver.com/music.mp3我的代码看起来像这样:Filef=newFile(newURL("http://www.myserver.com/music.mp3

Android MediaPlayer - 重新访问同时下载和流式传输

以前有人问过这个问题,但现在有了更新版本的Android(直到JellyBean),我想知道在同时下载和流式传输文件方面是否有任何进展。从API来看,它看起来不太可能,因为这些是可用的setDataSource方法:voidsetDataSource(Stringpath)Setsthedatasource(file-pathorhttp/rtspURL)touse.voidsetDataSource(Contextcontext,Uriuri,Mapheaders)SetsthedatasourceasacontentUri.voidsetDataSource(Contextcont

Android开发,VPNService.buider中的FileDescriptor不能读写

我正在尝试使用Android4.xVPN服务与内部以太网服务器建立VPN隧道。IP地址是Internet上的全局ip。现在问题是:1.我使用TCPdump抓包,VPNService.build建立后,没有一个tcp包可以在之前连接到服务器的隧道中传输。2.构建建立后,我得到一个fileDescriptor,它不能写入任何字节(EINVAL错误),也不能读取任何字节(长度=0)。3.我使用sockettunnel与服务器通信,发送PPTP包,经过start-control-request,outgoing-call-request,服务器返回正确的信息,然后通过PPPLCP协议(prot

android - MediaPlayer setDataSource,最好用path还是FileDescriptor?

假设我有一个文件的完整路径。将该文件加载到MediaPlayer中的更好方法是什么?StringfilePath="somepath/somefile.mp3";mediaPlayer.setDataSource(filePath);或StringfilePath="somepath/somefile.mp3";Filefile=newFile(filePath);FileInputStreaminputStream=newFileInputStream(file);mediaPlayer.setDataSource(inputStream.getFD());inputStream.c

android - MediaPlayer setDataSource,最好用path还是FileDescriptor?

假设我有一个文件的完整路径。将该文件加载到MediaPlayer中的更好方法是什么?StringfilePath="somepath/somefile.mp3";mediaPlayer.setDataSource(filePath);或StringfilePath="somepath/somefile.mp3";Filefile=newFile(filePath);FileInputStreaminputStream=newFileInputStream(file);mediaPlayer.setDataSource(inputStream.getFD());inputStream.c

android - FileDescriptor在Android中的实际系统文件描述符(作为int)

有没有办法从Android的FileDescriptor对象获取系统文件描述符(套接字或文件号作为int)?我想直接在JNI代码中访问文件描述符,而不使用任何Java包装器。编辑:我找到了getParcelFileDescriptorFD并且FileDescriptor具有名为“descriptor”的int字段,示例用法在media/jni/android_media_MediaPlayer.cpp中,func定义在frameworks/base/core/jni/android_util_Binder.cpp,字段本身在libcore/luni/src/main/java/java
12