當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。