मैं जो की तरह एक uri एक छविएंड्रॉइड में यूआरएल से बिटमैप कैसे प्राप्त करें?
file:///mnt/...............
इस uri का उपयोग कैसे करें छवि प्राप्त करने के लिए किया है, लेकिन यह शून्य देता है, कृपया मुझे बताओ जहां मैं गलत हूँ।
public static Bitmap getBitmapFromURL(String src) {
try {
URL url = new URL(src);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoInput(true);
connection.connect();
InputStream input = connection.getInputStream();
Bitmap myBitmap = BitmapFactory.decodeStream(input);
return myBitmap;
} catch (IOException e) {
e.printStackTrace();
return null;
}
} // Author: silentnuke
अपने मेनिफ़ेस्ट में इंटरनेट अनुमति जोड़ने के लिए मत भूलना:
Bitmap bitmap = BitmapFactory.decodeFile(uri.getPath());
Bitmap bitmap = BitmapFactory.decodeFile(uri.toString());
यह एक लाइनर नहीं है क्योंकि आपका यूआरएल ऑब्जेक्ट बनाने के प्रयास में घूमना चाहिए। – portfoliobuilder
यह विचार बिटमैप प्राप्त करने का एक लाइन तरीका था जिसे आपने पहले से ही एक यूआरएल परिभाषित किया था। – brthornbury
'url.openConnection()। GetInputStream()' को 'url.openStream()' –