UIImage, imageWithData in Android? - java

I'm fairly new in Android development so please forgive me if it's a stupid question.
Basically I have an iPhone app,which will compress UIImage into NSData, using UIImageJPEGRepresentation method, this is not a problem.
The question begins when I am trying to read this data on an Android device. I'm transferring the image data (NSData)from iPhone to Android, and I want to display the image on Android. How should I do so?
Is there any customised class that can do function similar to UIImage imageWithData in Java, that can decode the data and turn it into Bitmap?
Or should I try to encode and decode using a different but stand method? If so, what are the options?
Thank you so much for your help!

After further digging and researching, I found some interesting and useful classes if anyone is interested.
https://code.google.com/p/crossmobile/source/browse/src/xmioslayer/src/org/xmlvm/iphone/?r=68eaa3b2fa6ee05e8034bd517b45b490c50c7bb7
This is google cross mobile code, with them, you can use NSData and other class method that was originally meant for iOS developing.
However that's not how I solve the problem above.
There're two ways to pass an image from iPhone(UIImage) to Android(Bitmap), or the other way around.
First, upload the image into your own server, (by using AFNetwork in iOS, not sure about android), then get the url of the image, then pass this url to the other device as a string.
Or, convert UIImage to NSData, then from NSData to NSString (using Base64Encoding), then use NSJsonSerializatioin to parse whatever NSString, NSArray or NSDictionary to Json Object. Send the Json object, and try to decode it on the other device.
Although the first method is recommended, I actually went with the second one since I wish to deal the data locally with or without internet.
If anyone needs sample code, just ask, I'll post.
And that's pretty much it! Happy coding!

Related

Sending from web-service received VCard via email, without saving it on device storage

Here's the situation:
I get two VCards from our web-service and I have to share them via email (or any other suitable channel - not really relevant).
I could save them to files, and then send URIs to the intent using putParcelableArrayListExtra, but I'd really like not to use storage, because I'd rather not nag user with storage permissions just because of this.
I did see this solution, which looks like it does what I need to do (haven't tried it, yet). However, is there any cleaner way of achieving this?
Since there is limited amount of fields on the VCard (about 10), would it be okay to just make Parcelable object of my own, copy fields from received VCard and share it as text/x-vcard using putParcelableArrayListExtra?
I'd like someone to just steer me in the right direction, since I'm quite lost right now.
As Selvin said in the comment:
FileProvider is the answer ... you can share your app private file(so you don't need storage permissions) with other apps using it ... you may also use ContentProvider directly if you wana provide this information from memory/database directly

Interpreting iOS code to get Bluetooth Low Energy data on Android

I was sent iOS C code to get data from a Bluetooth Low Energy scale and I need to find out how to create similar functions into Android Java code.
The scale I am working with aren't using typical UUIDs and formatting.
I already have a scanner set up with the ability to write and listen to notifications.
What I need to do is figure out how to get the weight data.
I know is that 0XFFF0 is the service UUID, 0XFFF1 is the write characteristic and 0XFFF4 is the notify characteristic.
I'm guessing it writes something, then the scale gives you the data. But I'm not sure what.
Plus I think the scale sends the data with NSUTF8StringEncoding if I'm reading it correctly. How would I implement this on Java?
Here is the code sent to me:
http://www.anj.fyi/BTManagerlib.m (I tried to post the code here, but it's registering as spam for some odd reason)
I really appreciate the help guys.
Many thanks.
"The scale I am working with aren't using typical UUIDs and formatting."
Yes, it uses, except it is written in 16-bit format If you want 128-bit UUID use XXXXYYYY-0000-1000-8000-00805F9B34FB base to create it.
From the example that you have posted:
-(void)writeDataToBlue:(NSNotification *)note
{
id obj = [note object];
_senddata = obj;
[self sendBlueToothData:_senddata showAlert:YES];
}
it is clear that data to be written to the device are not bundled into the source code, but they are received via notification center, from some other class. Ask them for device documentation or full source code, otherwise you won't be able to make any conclusions.

Create an EGLContext in C++ and bind it to a Java GLSurfaceView

i try to create an EGLContext in C++ and bint it to a GLSurfaceView.
After some research on google and even here, i don't see something close to my problem.
It is possible to do this ?
I already know that i can do a NativeActivity, but i also need to use Java library for Loading Image, Audio, make HttpRequest, get Device information, etc.
Any help is welcome.

Android sync data to internat storage with Retrofit Service

I want to have some data stored in Device in order my application to work offline. They are plain java objects that are returned from a JSON web service. I use retrofit + GSON . The issue is how to store them.
WHAT I have tried
Tried to use Serializable interface at my java classes and during my sync() method when I fetch them from webservice I store them at a file. Performance is a bit poor at slow devices during sync. Not much but it is an issue.
WHAT I attempted
I attemted to store JSON from Response Retrofit. However it seems a bit of pain. Because it doesnt return as string the result but as InputStream. Then I have to convert back again.
WHAT I didnt do
I didnt try SQLite and any ORM. Seems overkill to me for 7 simple list of readonly List of objects. And I guess that performance is going to suffer more.
In IOS core data is easy to achieve this out of the box. Is there a solution for this in android ?
Best approach to this is to write the JSON out to a file using one of the near infinite number of free libraries or code samples, such as: http://www.mkyong.com/java/json-simple-example-read-and-write-json.

Conversion of text to picture-message?

Friends,
I need to know how to convert a text to a picture-message(.ota) format in JAVA for sending through mobiles? I am developing a software that sends the picture-message to another mobile via serial-port.
Could anyone help for creating a routine for the conversion process? I need that routine to converts the given text/picture to a .ota format?
Having read the article about the file format I would say it doesn't sound all that complicated. The basic steps are pretty much outlined and could be implemented within the hour.. Guessing you've that that already by now?
(And if so, mind sharing the code to solve the question? ;) Shouldn't need to be anything over a few hundred lines, right?)

Categories

Resources