当前位置: 首页>>代码示例>>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;未经允许,请勿转载。