当前位置: 首页>>代码示例>>Java>>正文


Java ParcelFileDescriptor.createPipe方法代码示例

本文整理汇总了Java中android.os.ParcelFileDescriptor.createPipe方法的典型用法代码示例。如果您正苦于以下问题:Java ParcelFileDescriptor.createPipe方法的具体用法?Java ParcelFileDescriptor.createPipe怎么用?Java ParcelFileDescriptor.createPipe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.os.ParcelFileDescriptor的用法示例。


在下文中一共展示了ParcelFileDescriptor.createPipe方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: openFile

import android.os.ParcelFileDescriptor; //导入方法依赖的package包/类
@Override
public ParcelFileDescriptor openFile(Uri uri, String mode) throws FileNotFoundException {
    ParcelFileDescriptor[] pipe;
    try {
        pipe = ParcelFileDescriptor.createPipe();

        String url = getFilePath(uri);
        Log.d(TAG, "Retrieving " + url);
        ByteArrayOutputStream stream = getDataForUrl(url);

        new TransferThread(stream, new AutoCloseOutputStream(pipe[1])).start();

    } catch (IOException e) {
        e.printStackTrace();
        throw new FileNotFoundException("Could not open pipe for: " + uri.toString());
    }
    return (pipe[0]);
}
 
开发者ID:dbrant,项目名称:zimdroid,代码行数:19,代码来源:ZimContentProvider.java

示例2: testBadFileDescriptorProvider

import android.os.ParcelFileDescriptor; //导入方法依赖的package包/类
@SmallTest
@Feature({"Cronet"})
public void testBadFileDescriptorProvider() throws Exception {
    TestUrlRequestCallback callback = new TestUrlRequestCallback();
    UrlRequest.Builder builder =
            new UrlRequest.Builder(NativeTestServer.getRedirectToEchoBody(), callback,
                    callback.getExecutor(), mTestFramework.mCronetEngine);
    ParcelFileDescriptor[] pipe = ParcelFileDescriptor.createPipe();
    try {
        UploadDataProvider dataProvider = UploadDataProviders.create(pipe[0]);
        builder.setUploadDataProvider(dataProvider, callback.getExecutor());
        builder.addHeader("Content-Type", "useless/string");
        builder.build().start();
        callback.blockForDone();

        assertTrue(callback.mError.getCause() instanceof IllegalArgumentException);
    } finally {
        pipe[1].close();
    }
}
 
开发者ID:lizhangqu,项目名称:chromium-net-for-android,代码行数:21,代码来源:UploadDataProvidersTest.java

示例3: pipeFrom

import android.os.ParcelFileDescriptor; //导入方法依赖的package包/类
public static ParcelFileDescriptor pipeFrom(InputStream inputStream)
        throws IOException {
    final ParcelFileDescriptor[] pipe = ParcelFileDescriptor.createPipe();
    final OutputStream output = new ParcelFileDescriptor.AutoCloseOutputStream(pipe[1]);

    new TransferThread(inputStream, output).start();

    return pipe[0];
}
 
开发者ID:medalionk,项目名称:simple-share-android,代码行数:10,代码来源:ParcelFileDescriptorUtil.java

示例4: pipeFrom

import android.os.ParcelFileDescriptor; //导入方法依赖的package包/类
public static ParcelFileDescriptor pipeFrom(InputStream inputStream)
        throws IOException {
    ParcelFileDescriptor[] pipe = ParcelFileDescriptor.createPipe();
    ParcelFileDescriptor readSide = pipe[0];
    ParcelFileDescriptor writeSide = pipe[1];

    new TransferThread(inputStream, new ParcelFileDescriptor.AutoCloseOutputStream(writeSide))
            .start();

    return readSide;
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:12,代码来源:ParcelFileDescriptorUtil.java

示例5: startPumpThread

import android.os.ParcelFileDescriptor; //导入方法依赖的package包/类
public ParcelFileDescriptor startPumpThread() throws IOException {
    if (writeSidePfd != null) {
        throw new IllegalStateException("startPumpThread() must only be called once!");
    }
    ParcelFileDescriptor[] pipe = ParcelFileDescriptor.createPipe();
    ParcelFileDescriptor readSidePfd = pipe[0];
    writeSidePfd = pipe[1];

    new DataSourceTransferThread(this, new ParcelFileDescriptor.AutoCloseOutputStream(writeSidePfd)).start();

    return readSidePfd;
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:13,代码来源:SMimeApi.java

示例6: pipeTo

import android.os.ParcelFileDescriptor; //导入方法依赖的package包/类
@SuppressWarnings("unused")
public static ParcelFileDescriptor pipeTo(OutputStream outputStream)
        throws IOException {
    final ParcelFileDescriptor[] pipe = ParcelFileDescriptor.createPipe();
    final InputStream input = new ParcelFileDescriptor.AutoCloseInputStream(pipe[0]);

    new TransferThread(input, outputStream).start();

    return pipe[1];
}
 
开发者ID:kranthi0987,项目名称:easyfilemanager,代码行数:11,代码来源:ParcelFileDescriptorUtil.java

示例7: NativePipe

import android.os.ParcelFileDescriptor; //导入方法依赖的package包/类
public NativePipe() {
    try {
        ParcelFileDescriptor[] pipe = ParcelFileDescriptor.createPipe();
        inputStream = new ParcelFileDescriptor.AutoCloseInputStream(pipe[0]) {
            private boolean closed = false;

            @Override
            public void close() throws IOException {
                if (closed) return;
                closed = true;
                super.close();
                outputStream.close();
            }
        };
        outputStream = new ParcelFileDescriptor.AutoCloseOutputStream(pipe[1]) {
            private boolean closed = false;

            @Override
            public void close() throws IOException {
                if (closed) return;
                closed = true;
                super.close();
                inputStream.close();
            }
        };
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:martinmarinov,项目名称:AndroidDvbDriver,代码行数:30,代码来源:NativePipe.java


注:本文中的android.os.ParcelFileDescriptor.createPipe方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。