當前位置: 首頁>>代碼示例>>Java>>正文


Java Uri.getSchemeSpecificPart方法代碼示例

本文整理匯總了Java中android.net.Uri.getSchemeSpecificPart方法的典型用法代碼示例。如果您正苦於以下問題:Java Uri.getSchemeSpecificPart方法的具體用法?Java Uri.getSchemeSpecificPart怎麽用?Java Uri.getSchemeSpecificPart使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.net.Uri的用法示例。


在下文中一共展示了Uri.getSchemeSpecificPart方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: readDataUri

import android.net.Uri; //導入方法依賴的package包/類
private OpenForReadResult readDataUri(Uri uri) {
    String uriAsString = uri.getSchemeSpecificPart();
    int commaPos = uriAsString.indexOf(',');
    if (commaPos == -1) {
        return null;
    }
    String[] mimeParts = uriAsString.substring(0, commaPos).split(";");
    String contentType = null;
    boolean base64 = false;
    if (mimeParts.length > 0) {
        contentType = mimeParts[0];
    }
    for (int i = 1; i < mimeParts.length; ++i) {
        if ("base64".equalsIgnoreCase(mimeParts[i])) {
            base64 = true;
        }
    }
    String dataPartAsString = uriAsString.substring(commaPos + 1);
    byte[] data = base64 ? Base64.decode(dataPartAsString, Base64.DEFAULT) : EncodingUtils.getBytes(dataPartAsString, "UTF-8");
    InputStream inputStream = new ByteArrayInputStream(data);
    return new OpenForReadResult(uri, inputStream, contentType, data.length, null);
}
 
開發者ID:aabognah,項目名稱:LoRaWAN-Smart-Parking,代碼行數:23,代碼來源:CordovaResourceApi.java

示例2: handleUninstallRequest

import android.net.Uri; //導入方法依賴的package包/類
private boolean handleUninstallRequest(Intent intent) {
    IAppRequestListener listener = VirtualCore.get().getAppRequestListener();
    if (listener != null) {
        Uri packageUri = intent.getData();
        if (SCHEME_PACKAGE.equals(packageUri.getScheme())) {
            String pkg = packageUri.getSchemeSpecificPart();
            try {
                listener.onRequestUninstall(pkg);
                return true;
            } catch (RemoteException e) {
                e.printStackTrace();
            }
        }

    }
    return false;
}
 
開發者ID:7763sea,項目名稱:VirtualHook,代碼行數:18,代碼來源:MethodProxies.java

示例3: getDataUriMimeType

import android.net.Uri; //導入方法依賴的package包/類
private String getDataUriMimeType(Uri uri) {
    String uriAsString = uri.getSchemeSpecificPart();
    int commaPos = uriAsString.indexOf(',');
    if (commaPos == -1) {
        return null;
    }
    String[] mimeParts = uriAsString.substring(0, commaPos).split(";");
    if (mimeParts.length > 0) {
        return mimeParts[0];
    }
    return null;
}
 
開發者ID:Andy-Ta,項目名稱:COB,代碼行數:13,代碼來源:CordovaResourceApi.java

示例4: readDataUri

import android.net.Uri; //導入方法依賴的package包/類
private OpenForReadResult readDataUri(Uri uri) {
    String uriAsString = uri.getSchemeSpecificPart();
    int commaPos = uriAsString.indexOf(',');
    if (commaPos == -1) {
        return null;
    }
    String[] mimeParts = uriAsString.substring(0, commaPos).split(";");
    String contentType = null;
    boolean base64 = false;
    if (mimeParts.length > 0) {
        contentType = mimeParts[0];
    }
    for (int i = 1; i < mimeParts.length; ++i) {
        if ("base64".equalsIgnoreCase(mimeParts[i])) {
            base64 = true;
        }
    }
    String dataPartAsString = uriAsString.substring(commaPos + 1);
    byte[] data;
    if (base64) {
        data = Base64.decode(dataPartAsString, Base64.DEFAULT);
    } else {
        try {
            data = dataPartAsString.getBytes("UTF-8");
        } catch (UnsupportedEncodingException e) {
            data = dataPartAsString.getBytes();
        }
    }
    InputStream inputStream = new ByteArrayInputStream(data);
    return new OpenForReadResult(uri, inputStream, contentType, data.length, null);
}
 
開發者ID:Andy-Ta,項目名稱:COB,代碼行數:32,代碼來源:CordovaResourceApi.java

示例5: shouldInterceptRequest

import android.net.Uri; //導入方法依賴的package包/類
protected WebResourceResponse shouldInterceptRequest(WebView webView, Uri uri) {
    if (!CID_SCHEME.equals(uri.getScheme())) {
        return RESULT_DO_NOT_INTERCEPT;
    }

    if (attachmentResolver == null) {
        return RESULT_DUMMY_RESPONSE;
    }

    String cid = uri.getSchemeSpecificPart();
    if (TextUtils.isEmpty(cid)) {
        return RESULT_DUMMY_RESPONSE;
    }

    Uri attachmentUri = attachmentResolver.getAttachmentUriForContentId(cid);
    if (attachmentUri == null) {
        return RESULT_DUMMY_RESPONSE;
    }

    Context context = webView.getContext();
    ContentResolver contentResolver = context.getContentResolver();
    try {
        String mimeType = contentResolver.getType(attachmentUri);
        InputStream inputStream = contentResolver.openInputStream(attachmentUri);

        WebResourceResponse webResourceResponse = new WebResourceResponse(mimeType, null, inputStream);
        addCacheControlHeader(webResourceResponse);
        return webResourceResponse;
    } catch (Exception e) {
        Timber.e(e, "Error while intercepting URI: %s", uri);
        return RESULT_DUMMY_RESPONSE;
    }
}
 
開發者ID:philipwhiuk,項目名稱:q-mail,代碼行數:34,代碼來源:K9WebViewClient.java

示例6: getPath

import android.net.Uri; //導入方法依賴的package包/類
private  String getPath(Uri uri){
    String path = uri.getSchemeSpecificPart();
    String part = uri.getSchemeSpecificPart();
    final int splitIndex = part.indexOf(':', 1);
    if(splitIndex != -1) {
        path = part.substring(splitIndex + 1);
    }
    return path;
}
 
開發者ID:medalionk,項目名稱:simple-share-android,代碼行數:10,代碼來源:NoteActivity.java

示例7: getValue

import android.net.Uri; //導入方法依賴的package包/類
@Override
public String getValue(ComponentName resolvedComponent, Intent intent,
                       String resolvedType) {
    Uri data = intent.getData();
    if (data != null) {
        return data.getSchemeSpecificPart();
    }
    return null;
}
 
開發者ID:TaRGroup,項目名稱:IFWManager,代碼行數:10,代碼來源:StringFilter.java


注:本文中的android.net.Uri.getSchemeSpecificPart方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。