private void startServiceConfig() { Log.i(TAG, "Starting service config"); String discoveryEndpoint = app.getString(R.string.discovery_endpoint); if (discoveryEndpoint.trim().length() == 0 || !URLUtil.isValidUrl(discoveryEndpoint)) { Log.i(TAG, "Using static service config"); AuthorizationServiceConfiguration serviceConfig = new AuthorizationServiceConfiguration( Uri.parse(app.getString(R.string.authorization_endpoint)), Uri.parse(app.getString(R.string.token_endpoint))); authState = new AuthState(serviceConfig); userInfoUrl = app.getString(R.string.user_info_endpoint); finishServiceConfig(); } else { Log.i(TAG, "Using discovery service config"); Uri discoveryUri = Uri.parse(discoveryEndpoint); loginListener.onEvent(AuthRepo.this, AUTH_SERVICE_DISCOVERY_START); AuthorizationServiceConfiguration.fetchFromUrl(discoveryUri, this::finishServiceDiscovery); } }
@AfterPermissionGranted(WRITE_EXTERNAL_REQUEST_CODE) public void downloadFile(String url, String userAgent, String contentDisposition, String mimetype) { DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url)); request.setMimeType(mimetype); cookieManager = CookieManager.getInstance(); PersistentConfig persistentConfig = new PersistentConfig(activity.getApplicationContext()); persistentConfig.setCookie(getCookies(Session.getSession(activity.getApplicationContext()))); cookieManager.setCookie(host, persistentConfig.getCookieString()); request.addRequestHeader("Cookie", getCookies(Session.getSession(activity.getApplicationContext()))); request.setDescription("Downloading file..."); request.setTitle(URLUtil.guessFileName(url, contentDisposition, mimetype)); request.allowScanningByMediaScanner(); request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); String fileName = URLUtil.guessFileName(url, contentDisposition, mimetype); request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, fileName); DownloadManager dManager = (DownloadManager) getActivity().getSystemService(DOWNLOAD_SERVICE); dManager.enqueue(request); }
@Override public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) { listener.onDownloadStart(); DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url)); request.setMimeType(mimetype); //------------------------COOKIE!!------------------------ CookieManager.getInstance().setCookie(url, getCookie()); String cookiesAlt = CookieManager.getInstance().getCookie(url); request.addRequestHeader(Constant.COOKIE, cookiesAlt); //------------------------COOKIE!!------------------------ request.addRequestHeader(Constant.USER_AGENT, userAgent); request.setDescription(activity.getString(R.string.downloading_file)); request.setTitle(URLUtil.guessFileName(url, contentDisposition, mimetype)); request.allowScanningByMediaScanner(); request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, URLUtil.guessFileName(url, contentDisposition, mimetype)); DownloadManager dm = (DownloadManager) activity.getSystemService(activity.DOWNLOAD_SERVICE); try { dm.enqueue(request); activity.showToast(R.string.downloading_file); } catch (Exception e) { activity.showToast(R.string.download_failed); } }
/** * 获取多个图片,并在全部完成的时候回调 * * @param context * @param urls * @param callback */ public static void fetch(final Context context, final LuaResourceFinder finder, final String[] urls, final LoadCallback callback) { if (context != null && urls != null && urls.length > 0) { final AtomicInteger count = new AtomicInteger(urls.length); final Map<String, Drawable> result = new HashMap<String, Drawable>(); for (final String url : urls) { if (URLUtil.isNetworkUrl(url)) {//network final ImageProvider imageProvider = LuaView.getImageProvider(); if (imageProvider != null) { imageProvider.preload(context, url, new DrawableLoadCallback() { @Override public void onLoadResult(Drawable drawable) { result.put(url, drawable); callCallback(count, callback, result); } }); } } else {//TODO 优化成异步 if (finder != null) { result.put(url, finder.findDrawable(url)); callCallback(count, callback, result); } } } } }
@Override public void onClick(View view){ if(view.getId()==R.id.notification_extra_info_tv){ String url = notifications.get(getAdapterPosition()).getExtraUrl(); if(URLUtil.isValidUrl(url)) { Utils.openLinkInCustomTab(context, url); } } else { if(descTv.getVisibility()==View.GONE){ expandView(); } else collapseView(); notifyViewToggle(getAdapterPosition()); } }
public void display(SimpleDraweeView view, String url, Postprocessor postprocessor) { if (!TextUtils.isEmpty(url)) { Uri uri; if (URLUtil.isNetworkUrl(url)) { uri = Uri.parse(url); } else { uri = Uri.fromFile(new File(url)); } ImageRequest request = ImageRequestBuilder .newBuilderWithSource(uri) .setPostprocessor(postprocessor) .setProgressiveRenderingEnabled(true) //.setResizeOptions(new ResizeOptions(100, 100)) .setLocalThumbnailPreviewsEnabled(true) .setRotationOptions(RotationOptions.autoRotateAtRenderTime()) .build(); controller = Fresco.newDraweeControllerBuilder() .setImageRequest(request) .setOldController(view.getController()) .build(); view.setController(controller); } }
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.layout_example: Intent i = new Intent(this, ExampleListActivity.class); startActivity(i); break; case R.id.about: Intent ii = new Intent(this, TestActivity.class); startActivity(ii); break; case R.id.main_in_webview: String url = mSearch.getText().toString(); if (URLUtil.isValidUrl(url)) { Intent intent = new Intent(this, WebViewActivity.class); intent.putExtra(EXTAL_URL, url); startActivity(intent); } else { Toast.makeText(this, "not valid url", Toast.LENGTH_LONG).show(); } break; } return super.onOptionsItemSelected(item); }
private boolean handleUrlLoading(WebView view, String url) { Log.d(TAG, "handleUrlLoading() called with: " + " url = [" + url + "]"); if (!(view instanceof PagerWebView)) { return false; } if (url.equals(view.getUrl())) { Log.d(TAG, "handleUrlLoading() is same as old url let webview process it " + url); return false; } mLastRequestTime = System.currentTimeMillis(); // Log.d(TAG, "**getUrl() " + view.getUrl()); // Log.d(TAG, "**getOriginalUrl() " + view.getOriginalUrl()); // Log.d(TAG, "**url " + url); if (URLUtil.isHttpUrl(url) || URLUtil.isHttpsUrl(url)) { if (!isUserClick(view)) { Log.d(TAG, "handleUrlLoading checkIfRedirectRequest is true processed by webview."); return false; } Log.d(TAG, "handleUrlLoading process by pager, create new page."); pager.loadUrl(url); return true; } return false; }
private boolean validateUrl(String url) { if (URLUtil.isHttpsUrl(url) || URLUtil.isHttpUrl(url)) { return true; } new AlertDialog.Builder(this) .setTitle(getText(R.string.invalid_url_title)) .setMessage(getString(R.string.invalid_url_text, url)) .setCancelable(false) .setNeutralButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }) .create() .show(); return false; }
public static boolean checkURL(CharSequence input) { if (TextUtils.isEmpty(input)) { return false; } Pattern URL_PATTERN = Patterns.WEB_URL; boolean isURL = URL_PATTERN.matcher(input).matches(); if (!isURL) { String urlString = input + ""; if (URLUtil.isNetworkUrl(urlString)) { try { new URL(urlString); isURL = true; } catch (Exception e) { } } } return isURL; }
public static boolean configHasRequiredFields(LEServiceConfiguration leServiceConfiguration) throws LEServiceException { boolean result = true; try { if (leServiceConfiguration.captureFlowLocale.isEmpty()) result = false; if (leServiceConfiguration.captureClientId.isEmpty()) result = false; if (leServiceConfiguration.captureApplicationId.isEmpty()) result = false; if (leServiceConfiguration.captureFlowVersion.isEmpty()) result = false; if (leServiceConfiguration.captureFlowName.isEmpty()) result = false; if (leServiceConfiguration.policyCheckerStage.isEmpty()) result = false; if (leServiceConfiguration.policyCheckerTenant.isEmpty()) result = false; if (!URLUtil.isValidUrl(leServiceConfiguration.policyCheckerHost)) result = false; }catch (Exception ex){ result = false; } if(!result) throw new LEServiceException("Invalid LEServiceConfiguration Detected"); return result; }
@Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { if (holder.getItemViewType() == TYPE_HEADER) { HeaderViewHolder headerViewHolder = (HeaderViewHolder) holder; String imageUri = mContext.getString(R.string.about_image); if (ColorHelper.isValidColor(imageUri)) { headerViewHolder.image.setBackgroundColor(Color.parseColor(imageUri)); } else if (!URLUtil.isValidUrl(imageUri)) { imageUri = "drawable://" + DrawableHelper.getResourceId(mContext, imageUri); ImageLoader.getInstance().displayImage(imageUri, headerViewHolder.image, ImageConfig.getDefaultImageOptions()); } else { ImageLoader.getInstance().displayImage(imageUri, headerViewHolder.image, ImageConfig.getDefaultImageOptions()); } String profileUri = mContext.getResources().getString(R.string.about_profile_image); if (!URLUtil.isValidUrl(profileUri)) { profileUri = "drawable://" + DrawableHelper.getResourceId(mContext, profileUri); } ImageLoader.getInstance().displayImage(profileUri, headerViewHolder.profile, ImageConfig.getDefaultImageOptions()); } }
@Override public void onClick(View view) { switch (view.getId()) { case R.id.btn_host_add: if (editUrl.getText().toString().length() > 0 && editName.getText().toString().length() > 0 && editLogin.getText().toString().length() > 0) { if (URLUtil.isValidUrl(editUrl.getText().toString())) { performAdd(); } else { Toast.makeText(this, getString(R.string.url_invalid), Toast.LENGTH_SHORT).show(); } } else { Toast.makeText(this, getString(R.string.fill_fields), Toast.LENGTH_SHORT).show(); } break; } }
public String create(Request request) { String id = this.generateId(); okhttp3.Request.Builder builder = new okhttp3.Request.Builder(); builder.tag(id); builder.url(request.getUrl()); if (request.getHeaders().size() > 0) { builder.headers(Headers.of(request.getHeaders())); } if (request.getFileName() == null) { request.setFileName(URLUtil.guessFileName(request.getUrl(), null, null)); } if (request.getFilePath() == null) { String path = getApplicationContext().getApplicationInfo().dataDir.concat("/fancy_downloader"); File dir = new File(path); if (!dir.exists()) { dir.mkdir(); } request.setFilePath(path); } okhttp3.Request dRequest = builder .build(); Call call = client.newCall(dRequest); this.tasks.put(id, new Task(dRequest, request, call)); return id; }
public static boolean isValidSearchQueryUrl(String url) { String trimmedUrl = url.trim(); if (!trimmedUrl.matches("^.+?://.+?")) { // UI hint url doesn't have http scheme, so add it if necessary trimmedUrl = "http://" + trimmedUrl; } if (!URLUtil.isNetworkUrl(trimmedUrl)) { return false; } if (!trimmedUrl.matches(".*%s$")) { return false; } return true; }
private boolean shouldOverrideLoading(@NonNull WebView view, @NonNull String url) { // Check if configured proxy is available if (!mProxyUtils.isProxyReady(mActivity)) { // User has been notified return true; } Map<String, String> headers = mLightningView.getRequestHeaders(); if (mLightningView.isIncognito()) { // If we are in incognito, immediately load, we don't want the url to leave the app return continueLoadingUrl(view, url, headers); } if (URLUtil.isAboutUrl(url)) { // If this is an about page, immediately load, we don't need to leave the app return continueLoadingUrl(view, url, headers); } if (isMailOrIntent(url, view) || mIntentUtils.startActivityForUrl(view, url)) { // If it was a mailto: link, or an intent, or could be launched elsewhere, do that return true; } // If none of the special conditions was met, continue with loading the url return continueLoadingUrl(view, url, headers); }
private void homePicker() { String currentHomepage; mHomepage = mPreferenceManager.getHomepage(); if (!URLUtil.isAboutUrl(mHomepage)) { currentHomepage = mHomepage; } else { currentHomepage = "https://www.google.com"; } BrowserDialog.showEditText(mActivity, R.string.title_custom_homepage, R.string.title_custom_homepage, currentHomepage, R.string.action_ok, new BrowserDialog.EditorListener() { @Override public void onClick(String text) { mPreferenceManager.setHomepage(text); home.setSummary(text); } }); }
@Override public void loadImage(ImageView imageView, String imagePath, int width, int height) { if (URLUtil.isNetworkUrl(imagePath)) { Picasso.with(imageView.getContext()) .load(imagePath) .centerCrop() .resize(width, height) .into(imageView); } else { Picasso.with(imageView.getContext()) .load(new File(imagePath)) .centerCrop() .resize(width, height) .into(imageView); } }
public static String decodeUri(final byte[] serviceData, final int start, final int length) { if (start < 0 || serviceData.length < start + length) return null; final StringBuilder uriBuilder = new StringBuilder(); int offset = 0; if (offset < length) { byte b = serviceData[start + offset++]; String scheme = URI_SCHEMES.get(b); if (scheme != null) { uriBuilder.append(scheme); if (URLUtil.isNetworkUrl(scheme)) { return decodeUrl(serviceData, start + offset, length - 1, uriBuilder); } else if ("urn:uuid:".equals(scheme)) { return decodeUrnUuid(serviceData, start + offset, uriBuilder); } } Log.w(TAG, "decodeUri unknown Uri scheme code=" + b); } return null; }
/** * Creates the Uri string with embedded expansion codes. * * @param uri to be encoded * @return the Uri string with expansion codes. */ public static byte[] encodeUri(String uri) { if (uri.length() == 0) { return new byte[0]; } ByteBuffer bb = ByteBuffer.allocate(uri.length()); // UUIDs are ordered as byte array, which means most significant first bb.order(ByteOrder.BIG_ENDIAN); int position = 0; // Add the byte code for the scheme or return null if none Byte schemeCode = encodeUriScheme(uri); if (schemeCode == null) { return null; } String scheme = URI_SCHEMES.get(schemeCode); bb.put(schemeCode); position += scheme.length(); if (URLUtil.isNetworkUrl(scheme)) { return encodeUrl(uri, position, bb); } else if ("urn:uuid:".equals(scheme)) { return encodeUrnUuid(uri, position, bb); } return null; }
private boolean saveMediaItem() { if (etMediaName.getText().toString().length() < MIN_TITLE_LENGTH) { Toast.makeText(getActivity(), getString(R.string.title_too_short), Toast.LENGTH_SHORT).show(); return false; } else if (!URLUtil.isValidUrl(etMediaUrl.getText().toString())) { Toast.makeText(getActivity(), getString(R.string.url_not_correct), Toast.LENGTH_SHORT).show(); return false; } if (mediaItemType == MediaItemType.RADIO) { StreamUrl streamUrl = new StreamUrl(etMediaUrl.getText().toString()); RadioItem radioItem = new RadioItem(etMediaName.getText().toString(), streamUrl, ""); ProfileManager.getInstance().addSubscribedMediaItem(radioItem); Toast.makeText(getActivity(), getString(R.string.radio_added), Toast.LENGTH_SHORT).show(); } else if (mediaItemType == MediaItemType.PODCAST) { Podcast podcast = new Podcast(etMediaName.getText().toString(), etMediaUrl.getText().toString()); ProfileManager.getInstance().addSubscribedMediaItem(podcast); Toast.makeText(getActivity(), getString(R.string.podcast_added), Toast.LENGTH_SHORT).show(); } return true; }
@Override protected void onTryUpdate(int reason) throws RetryException { try { if (!URLUtil.isValidUrl(getString(R.string.wallpaper_json))) return; Wallpaper wallpaper = MuzeiHelper.getRandomWallpaper(this); if (Preferences.get(this).isConnectedAsPreferred()) { if (wallpaper != null) { Uri uri = Uri.parse(wallpaper.getURL()); publishArtwork(new Artwork.Builder() .title(wallpaper.getName()) .byline(wallpaper.getAuthor()) .imageUri(uri) .build()); scheduleUpdate(System.currentTimeMillis() + Preferences.get(this).getRotateTime()); } } Database.get(this).closeDatabase(); } catch (Exception ignored) {} }
/** * Synchronously download image and return its bitmap * * @param imgUrl - url of image * @return bitmap of downloaded image or null */ @WorkerThread public static @Nullable Bitmap getBitmapFromImgUrlSync(@Nullable String imgUrl) { if (!URLUtil.isValidUrl(imgUrl)) { return null; } Bitmap bitmap = null; try { bitmap = PICASSO .load(imgUrl) .get(); } catch (IOException e) { e.printStackTrace(); } return bitmap; }
@Override public boolean shouldOverrideUrlLoading(WebView view, String url) { Log.d(SmartConstants.APP_NAME, "shouldOverrideUrlLoading->url:" + url); // Special handling for shouldOverrideUrlLoading // Make sure that we call the base class implementation and do // not interfere // with the base class redirects boolean redirected = super.shouldOverrideUrlLoading(view, url); Log.d(SmartConstants.APP_NAME, "shouldOverrideUrlLoading->redirected:" + redirected); // Do your own redirects here and set the return flag if (!redirected) { // Redirect HTTP and HTTPS urls to the external browser if (url != null && URLUtil.isHttpUrl(url) || URLUtil.isHttpsUrl(url)) { view.getContext().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); redirected = true; } } return redirected; }
protected String doInBackground(Void... args) { String url = start_url; int ttl = max_ttl; int type = NONE; if ( url != null && url.length() != 0 && URLUtil.isValidUrl(url) ) { type = playlistType(url); } else { url = null; } if (url != null && type != NONE ) { ttl -= 1; url = selectUrlFromPlaylist(url,type); } if (ttl == 0) url = null; return url; }
public void download(String url, int width, int height, DownloadListener listener) { mHandler = new Handler(Looper.getMainLooper()); if (listener == null) { Log.w(TAG, "download won't start since there is no assigned listener to It"); } else { mDownloadListener = listener; mURL = url; mWidth = width; mHeight = height; if (TextUtils.isEmpty(url)) { invokeFail(new Exception("Image URL is empty")); } else if (URLUtil.isHttpUrl(url) || URLUtil.isHttpsUrl(url)) { downloadImage(); } else if (URLUtil.isFileUrl(url)) { loadCachedImage(); } else { invokeFail(new Exception("Wrong file URL!")); } } }
private void showCustomEndpointDialog() { final View view = View.inflate(this, R.layout.custom_endpoint_layout, null); final EditText customEndpointEditText = ButterKnife.findById(view, R.id.custom_endpoint_edit_text); new AlertDialog.Builder(this) .setTitle("Change endpoint") .setView(view) .setPositiveButton(android.R.string.yes, (dialog, which) -> { final String url = customEndpointEditText.getText().toString(); if (URLUtil.isValidUrl(url)) { setEndpointAndRelaunch(ApiEndpoint.from(url)); } }) .setNegativeButton(android.R.string.cancel, (dialog, which) -> { dialog.cancel(); }) .setIcon(this.icDialogAlertDrawable) .show(); }
private boolean validateUrl(String url) { if (URLUtil.isHttpsUrl(url) || URLUtil.isHttpUrl(url)) { return true; } new AlertDialog.Builder(this) .setTitle(getText(R.string.invalid_url_title)) .setMessage(getString(R.string.invalid_url_text, url)) .setCancelable(false) .setNeutralButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }).create().show(); return false; }
public void setRedditItem(RedditItem redditItem, Picasso picasso) { title.setText(redditItem.title); description.setText(redditItem.selftext); upVotes.setText(String.format("%s", redditItem.score)); subreddit.setText(redditItem.subreddit); if (redditItem.selftext != null) { description.setVisibility(View.VISIBLE); description.setText(redditItem.selftext); } else { description.setVisibility(View.GONE); } if (URLUtil.isValidUrl(redditItem.thumbnail)) { postImage.setVisibility(View.VISIBLE); picasso.load(redditItem.thumbnail) .centerCrop().placeholder(R.drawable.ic_image).fit().into(postImage); } else { postImage.setVisibility(View.GONE); } }
/** * get emoticon from url * * @return emoticon name if exist. null if not */ @Nullable public static String parseEmoticonName(@Nullable String url) { if (TextUtils.isEmpty(url)) { return null; } // url has no domain if it comes from BASE_URL server. if (!URLUtil.isNetworkUrl(url)) { if (url.startsWith(Api.URL_EMOTICON_IMAGE_PREFIX)) { return url.substring(Api.URL_EMOTICON_IMAGE_PREFIX.length()); } } else if (url.startsWith(Api.BASE_URL + Api.URL_EMOTICON_IMAGE_PREFIX)) { return url.substring((Api.BASE_URL + Api.URL_EMOTICON_IMAGE_PREFIX).length()); } else if (url.startsWith(Api.BASE_STATIC_URL + Api.URL_EMOTICON_IMAGE_PREFIX_STATIC)) { return url.substring((Api.BASE_STATIC_URL + Api.URL_EMOTICON_IMAGE_PREFIX_STATIC).length()); } return null; }
/** * Generates the callback Uri for the given domain. * * @return the callback Uri. */ public static String getCallbackUri(@NonNull String scheme, @NonNull String packageName, @NonNull String domain) { if (!URLUtil.isValidUrl(domain)) { Log.e(TAG, "The Domain is invalid and the Callback URI will not be set. You used: " + domain); return null; } Uri uri = Uri.parse(domain) .buildUpon() .scheme(scheme) .appendPath("android") .appendPath(packageName) .appendPath("callback") .build(); Log.v(TAG, "The Callback URI is: " + uri); return uri.toString(); }
public static boolean openUrlByBrowser(Context context, String url) { if (TextUtils.isEmpty(url)) { return false; } final String HTTP_TAG = "http://"; url = url.trim(); if (!URLUtil.isNetworkUrl(url)) { url = HTTP_TAG + url; } try { Uri uri = Uri.parse(url); Intent intent = new Intent(Intent.ACTION_VIEW); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setData(uri); context.startActivity(intent); } catch (ActivityNotFoundException e) { e.printStackTrace(); return false; } return true; }
public CustomWebView(final Context context, String ref, boolean dynamic) { super(context); FAIMSApplication.getInstance().injectMembers(this); this.ref = ref; this.dynamic = dynamic; webPageStack = new Stack<WebPage>(); this.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { if (URLUtil.isFileUrl(url)) { String html = FileUtil.readFileIntoString(url.replace("file://", "")); loadDataWithBaseURL(html, "text/html", "utf-8", ""); return true; } else { Uri uri = Uri.parse(url); Intent intent = new Intent(Intent.ACTION_VIEW, uri); context.startActivity(intent); return true; } } }); cssManager.addCSS(this, "web-view"); }
@Override public void surfaceCreated(SurfaceHolder holder) { if (URLUtil.isNetworkUrl(url)) {//网络视频 try { //播放并缓冲到本地 new Thread(new CacheNetFileR()).start(); } catch (Exception e) { mHandler.sendEmptyMessage(NETWORK_PARSE_ERROE); e.printStackTrace(); } } else { File videoFile = new File(url); if (videoFile.exists()) { readSize = mediaLength = videoFile.length(); System.out.println("这是本地视频,直接播放!"); mHandler.sendEmptyMessage(VIDEO_STATE_BEGIN); } } }
public static Bitmap readImage(Context context, Uri uri, Options opts) { String scheme = uri.getScheme(); Bitmap bmp = null; if (URLUtil.isNetworkUrl(uri.toString())) { bmp = readImageWithUrl(uri.toString(), opts); } else if (ContentResolver.SCHEME_FILE.equals(scheme)) { bmp = readImage(uri.getPath(), opts); } else if (ContentResolver.SCHEME_CONTENT.equals(scheme)) { InputStream in = null; try { in = context.getContentResolver().openInputStream(uri); bmp = readImage(in, opts); } catch (FileNotFoundException e) { L.e(BitmapUtils.class, e); } finally { FileUtils.closeIO(in); } } else { throw new IllegalArgumentException("不支持的Uri: " + uri.toString()); } return bmp; }