Make an app to upload image to server in codenameone - java

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

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.

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

Android: custom Facebook integration

I need some advice for this matter...
I used the facebook android sdk to create an integration with facebook from my application...I followed this tutorial:
http://www.integratingstuff.com/2010/10/14/integrating-facebook-into-an-android-application/
I would need to implement authentication in one activity and the function postToWall in another.... after authentication i want to send post simply by pressing a button but in other activity, different from that where i do authentication.
is it possible? or with the SDK I'm forced to do everything together in the same activity?
thanks in advance
Yes it is possible. You will get a access token which you can send to the next activity. Use getAccessToken() and setAccessToken().
Here is an example that even saves the needed data: Contact-Picture-Sync
you need to install an extension, similar to the core Android SDK, but no, here is what you need to do:
1.) go to github.com/facebook/facebook-android-sdk
2.) download the facebook directory ONLY! The other directories are only examples.
3.) Put the files from the src (you can copy the drawables too, if you want to) in the package, you are currently working with
4.) You are good to go, you can use the facebook "SDK"
see also this example https://github.com/facebook/facebook-android-sdk/tree/master/examples/Hackbook download it , it is working example provided by facebook
just to provide an alternative answer, there's other ways of implementing sharing on Android.
It allows for more sharing options (like Twitter, QR-Barcodes, blogging and whatnot) without having to deal with the facebook android sdk.
What you would use is a "share" intent, like so:
String title = "My thing"; // used if you share through email or channels that require a headline for the content, always include this or some apps might not parse the content right
String wallPost = "Hey - check out this stuff: http://link.com "; // the content of your wallpost
String shareVia = "Share this stuff via"; // the headline for your chooser, where the phones avaliable sharing mechanisms are offered.
Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
shareIntent.setType("text/plain");
shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, title);
shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, wallPost);
startActivity(Intent.createChooser(shareIntent, shareVia));
This is by far the preferred solution on Android if you're looking for simple sharing, as it makes your app future-compatible with new services. And more lean and flexible for the user too, as there's little to no friction from hitting the share button to posting content.
It can also be seen in this blog post: http://android-developers.blogspot.com/2012/02/share-with-intents.html
I hope you can use this for your project.

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

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

Categories

Resources