I have made an android app,In that in an activity I have one imageView,I want to display an image to it using imageLoader,I have been used so many time imageloader,But i got this type of error Image can't be decoded ,My code is as below,Please help me for it,
code
iv_profile = (ImageView) findViewById(R.id.iv_profile);
imageLoader = ImageLoader.getInstance();
imageLoader.init(ImageLoaderConfiguration.createDefault(HomeActivity.this));
options = new DisplayImageOptions.Builder().cacheOnDisc(true).showStubImage(R.drawable.noimage).showImageOnFail(R.drawable.noimage).build();
String img = "http://tp.epagestore.in/" + Pref.getValue(HomeActivity.this, Const.PREF_PHOTO, "");
imageLoader.displayImage(img, iv_profile, options);
Related
I know there are several questions about this.
I have the following code:
Image image = new Image();
UriImageSource imgSource = new UriImageSource();
imgSource.SetBinding( UriImageSource.UriProperty, "ThumbnailUri" );
imgSource.Parent = image;
...
The problem is I don't know how to integrate imgSource to image object ?
Means how to add as child the imgSource to image ?
I set imgSource.Parent = image; but image is not visible in list view UI.
I have a model which contains a property like:
Uri ThumbnailUri {get;set;}
And I want to display that image in list view.
Image has a Source property
image.Source = imgSource;
when I am trying to upload the default image with captured image,it is not displaying.If I login again then that captured image will display.Why the default image is not changing? In case if the image already exists in the server, it works fine for me.
this is my code.I am using com.android.volley.toolbox.NetworkImageView
String url = "http://xxx.xxx.x.xx/mobile_app/" + img_path + "/" + img_name;
imageLoader = MyVolleyRequest.getInstance(StudentDetails.this).getImageLoader();
imageLoader.get(url, imageLoader.getImageListener(resultIv,R.drawable.new_back, R.drawable.new_back));
resultIv.setImageUrl(url, imageLoader);
Please help me to find the solution.
I got json data in this way:
{"data":[{"img_name":"abc.jpeg","img_path":"6"}]}
Now How can I display this image in image view in my android application.Please help me to solve.
Not sure if this is what you want.
First you need to parse the JSON and get the img_path and img_name. Then you can create the url of the image. The url generation logic depends on your server logic.
Something like this,
JSONObject data = new JSONObject(your_json_data);
String img_path = data.getString("img_path");
String img_name = data.getString("img_name");
String url = "http://xxx.xxx.x.x/" + img_path + "/" + img_name;
Use an imageloader like Picasso to load the image.
Hi am working on a video app in android i want to generate video thumbnail and send to the server or simple how can i get video thumbnail and store in server so that when i retrieve the video i can also get the video thumbnail to use in a recycle view thanks
Bitmap thumb = ThumbnailUtils.createVideoThumbnail(filePath,
MediaStore.Images.Thumbnails.MINI_KIND);
BitmapDrawable bitmapDrawable = new BitmapDrawable(thumb);
vidPreview.setBackgroundDrawable(bitmapDrawable);
I assume you are sending the video to the server also? If so then it may be better to generate the thumbnail on the server as you usually have more processing power there and less worry about consuming battery. It also saves you having to send the generated thumbnail to the server.
If you do want to create the thumbnail on the Android device then the following code will work (before this chunk the app has loaded all the videos in Media Store using the loader pattern and they are accessible via the 'cursor' variable below) - see the 'getThumbnail' method call:
while (videoCursor.moveToNext()) {
//Create the Thumbnail for this video
Log.d("ItemListFragment", "onLoadFinished: Creating Thumbnail");
String videoTitle = videoCursor.getString(titleColumn_index);
String videoPath = videoCursor.getString(pathColumn_index);
long videoID = videoCursor.getLong(idColumn_index);
Bitmap thisVideoThumbnail = MediaStore.Video.Thumbnails.getThumbnail(this.getActivity().getContentResolver(), videoID, MediaStore.Images.Thumbnails.MINI_KIND, null);
if (thisVideoThumbnail == null) {
Log.d("VideoContent refresh ","VideoThumbnail is null!!!");
}
VideoItem newVideoItem = new VideoItem(videoID, videoTitle, videoPath, thisVideoThumbnail);
//Add the new video item to the list
videosArray.addItem(newVideoItem);
}
I'd like to load image which is on SDCARD in folder to imageView of my cell in listView. I've tried different solutions but each of them fails. When I load images normally as it is in every base tutorial everything works. I've observed that, my application slows down when it has to load many images. Images are taken from photo camera of device. I'd like to load each of them asynchronously to avoid UI slow reaction. I've tried to use Thread, Asynctask but each of them throws error: "Only the oryginal thread that created a view hierarchy can touch its views". How to load images to avoid speed problems? SDImageLoader is a class which is possible to get from GITHUB. What I've tried is a standard code but is slows:
In a getView method in ListAdapter:
File imageFile = new File(Options.PATH_TO_FOLDER_PHOTOS_OF_APP + "test.png");
String imageFileString = Options.PATH_TO_FOLDER_PHOTOS_OF_APP + "test.png";
// "test.png" is a test file. Each cell will have different name of file to load.
if(imageFile.exists())
{
Bitmap myBitmap = BitmapFactory.decodeFile(imageFile.getAbsolutePath());
image.setImageBitmap(myBitmap);
// final SDImageLoader loader = new SDImageLoader(context);
// new SDImageLoader().load(imageFileString, image);
//UrlImageViewHelper.setUrlDrawable(image, url);
}
else
{
final SDImageLoader loader = new SDImageLoader();
Resources resources = context.getResources();
int resurceId;
resurceId = resources.getIdentifier("bad", "drawable",context.getPackageName());
loader.load(imageFileString, image);
image.setImageResource(resurceId);
}
Have you tried to refresh your project after adding an external library to your project? It doesn't matter with the fragment. You send exact context to the List Adapter - which should be fragment.this.getActivity().