"setImageDrawable(Drawable.createFromPath)" get image from web server Android - java

I am using the the gridView example from the developer.android.com site. But they are using images saved in the res/drawable folder. I want to try and set the images to come from my web server.
private Integer[] mThumbIds={
for(int i=0;i<myJSONArray.lenght();i++){
Object[] myJSONArray;
setImageDrawable(Drawable.createFromPath(String "www.mywebsite.com: + myJSONArray[i]).thumb);
};
};
Am I on the correct path to accomplish this? I am looking for advice or documentations/tutorials on this process. Thanks in advance.

I modified the GreenDroid library to do it for me - it has a nice set of imageloading classes. It takes some slight modification if you don't want to use their actionbar (I didn't see an easy way to do it without modification). Everything is also async : D !

this way you cant create Drawable from internet, for that you have first download content & make it Drawable refer this

Related

JAVA-OpenCV: Video Writer not opening

I want to save the video I'm capturing with opencv in Android and I've chosen to use the openCV VideoWriter class (if there's a better way for Android please let me know).
The problem is that I'm not being capable of opening the object.
This is what I'm trying
videoWriter = new VideoWriter("saved_video.avi", VideoWriter.fourcc('M','J','P','G'),
25.0D, new Size(mOpenCvCameraView.getWidth(),mOpenCvCameraView.getHeight()));
videoWriter.open("saved_video.avi", VideoWriter.fourcc('M','J','P','G'),
25.0D, new Size(mOpenCvCameraView.getWidth(),mOpenCvCameraView.getHeight()));
I keep getting videoWriter.isOpened()=false when it should be true.
Does anyone know what I'm doing wrong? Thanks in advance
The problem was the video path! It should be fully stated, like:
pathSavedVideoFolder = getExternalFilesDir(null).getPath();
filenameRawVideo = pathSavedVideoFolder + "/SavedVideo.avi";
After this you just need to refresh in order to see the file inside "Android/data/YOUR PROJECT/files" folder.

Make an app to upload image to server in codenameone

I was using android studio for last three months but when I moved to codename one I cant get a idea as everything seems so different and I don't know where to begin. I want to choose image from gallery on button click and upload it to a server.Can you help me shai ?
It's actually much simpler than Android:
MultipartRequest request = new MultipartRequest();
request.setUrl(url);
request.addData("myFileName", fullPathToFile, "text/plain")
NetworkManager.getInstance().addToQueue(request);
Taken from the JavaDoc here: https://www.codenameone.com/javadoc/com/codename1/io/MultipartRequest.html

Android Studio MainActivity.java can't find resources

I'm basically writing my first hello world in android studio and the java file says that the xml layout file and other resources in the res file don't exist. I took the references to these things from books/tutorials so they should work.
The book said to use
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main.xml);
}
But when that didn't work I changed it to res.layout.activity_main.xml
my project directory looks like this
How do I make it work?
http://i.stack.imgur.com/N71sl.png
//EDIT
http://i.stack.imgur.com/HUgsm.png
You are referencing res not R.
do something like this: setContentView( R.layout.activity_main);
Leave off the ".xml"
update your android studio in stable channel and restart android studio and build the project again .
You need to understand the concept of the R class in android.
The R class is auto generated every time you build your project and cannot be modified.
This class contains a map of all the projects assets. Every time you created or import a resource, set a dimension, a string, create a layout, add or change id etc. the R file is changed in the background.
So if you want to access a resource you simply call it using the R class.
For example:
layout: R.layout.activity_main
string: R.string.hello_world
id: R.id.et_main_helloWorld
And so on.
More info can be found here.
Make sure you also check Providing Resources and Accessing Resources for a better understanding.
Good luck and happy coding.
In the end I started a new project and added in everything piece by piece, I had put a mp3 file in the values directory which was messing up the R file.

how can I create a thumbnail of a video url in android?

I have a problem, I can only create thumbnails of local video files but not of a remote url, here is my code:
bmThumbnail = ThumbnailUtils.extractThumbnail(ThumbnailUtils.createVideoThumbnail("http://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4", MediaStore.Video.Thumbnails.MINI_KIND), 50, 50);
I hope you can help me,
regards
christian
I suppose there is no easy way to build the thumbnail without actually downloading the video locally.
So if your question is 'Can I get a thumbnail without having to download the full video?', I'd say...no.
Otherwise, once you have downloaded the video locally, then I guess you can perfectly use ThumbnailUtils.createVideoThumbnail(...) by giving the path to the downloaded file.
I also have the same problem - but what can I say from my tests:
The problem occurs only on android >2.3
in android 2.0 -> 2.3 You can use just
Bitmap thumbnail = ThumbnailUtils.createVideoThumbnail( videoUrl, MediaStore.Video.Thumbnails.MINI_KIND);
I hope someone explain what change is on android 4. it doesn't work
I have no problem generating thumbnails from remote videos with the following code:
final Bitmap thumbnail = ThumbnailUtils.createVideoThumbnail( videoUrl, MediaStore.Video.Thumbnails.MINI_KIND );
You don't have to wrap an extractThumbnail() call around it

Select Multiple images from phone's gallery using phonegap

I am using phonegap to select images from device's photo gallery.The code I am using is
onclick="pickFromPhotoGallery(pictureSource.PHOTOLIBRARY)"
and
function pickFromPhotoGallery(source){
navigator.camera.getPicture(getImageURI, function(){}, { quality: 50,
destinationType: destinationType.FILE_URI,
sourceType: source });
}
This allows me to select only one image at a time. I want to select multiple images at a time.
Is there a way to do this please?
Thanks.
No, there is currently no way to do this. Please open an enhancement request on JIRA.
https://issues.apache.org/jira/browse/CB

Categories

Resources