Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8602063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:59:21+00:00 2026-06-12T01:59:21+00:00

I want to implement a behavior similar to Whatsapp, where when the user can

  • 0

I want to implement a behavior similar to Whatsapp, where when the user can upload an image. I tried opening the images in my app, but if the image is too large, I will have an out of memory error.

To solve this, I’m opening forwarding the images to be open in the phone’s native image viewer using the platformRequest() method.

However, I want to know how is it Whatsapp modifies the phone’s native image viewer to add a “Select” button, with which the user selects the image he wants to upload. How is that information sent back to the J2ME application and how is the image resized?


Edit:
I tried this in two different ways, both of which gave me the OOME.

At first, I tried the more direct method:

FileConnection fc = (FileConnection) Connector.open("file://localhost/" + currDirName + fileName);
if (!fc.exists()) {
    throw new IOException("File does not exists");
}
InputStream fis = fc.openInputStream();
Image im = Image.createImage(fis);
fis.close();

When that didn’t work, I tried a more “manual” approach, but that gave me an error as well.

FileConnection fc = (FileConnection) Connector.open("file://localhost/" + currDirName + fileName);
if (!fc.exists()) {
    throw new IOException("File does not exists");
}
InputStream fis = fc.openInputStream();

ByteArrayOutputStream file = new ByteArrayOutputStream();
int c;

byte[] data = new byte[1024];

while ((c = fis.read(data)) != -1) {
    file.write(data, 0, c);

}

byte[] fileData = null;
fileData = file.toByteArray();

fis.close();
fc.close();
file.close();
Image im = Image.createImage(fileData, 0, fileData.length);

When I call the createImage method, the out of memory error occurs in both cases.
This varies with the devices. An E72 gives me the error with 3MB images, while a newer device will give me the error with images larger than 10MBs.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T01:59:22+00:00Added an answer on June 12, 2026 at 1:59 am

    MIDP 2 (JSR 118) does not have API for that, you need to find another way to handle big images.

    As for WhatsApp, it looks like they do not rely on MIDP in supporting this functionality. If you check the Wikipedia page you’ll note that they don’t claim general Java ME as supported platform, but instead, list narrower platforms like Symbian, S40, Blackberry etc.

    This most likely means that they implement “problematic features” like one you’re asking about using platform-specific API of particular target devices, having essentially separate projects / releases for every platform listed.

    If this feature is really necessary in your application, you likely will have to do something like this.

    In this case, consider also encapsulating problematic features in a way to make it easier to switch just part of your source code when building it for different platforms. For example, Class.forName(String) can be used to load platform specific implementation depending on target platform.

    //...
    Image getImage(String resourceName) {
       // ImageUtil is an interface with method getImage
       ImageUtil imageUtil = (ImageUtil) Class.forName(
               // get platform-specific implementation, eg
               //   "mypackage.platformspecific.s40.S40ImageUtil"
               //   "mypackage.platformspecific.bb.BBImageUtil"
               //   "mypackage.platformspecific.symbian.SymbialImageUtil"
               "mypackage.platformspecific.s40.S40ImageUtil");
       return imageUtil.getImage(resourceName);
    }
    //...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to implement a docking library in wpf with behavior similar to Adobe
I want implement in my software solution an VBA editor but in c# 3.0.
I want to implement an application which will work as a parser. User will
I want to implement a very similar functionality to what Apple did in the
I want to implement auto-completion feature for my CLI application. The default behavior of
I want to implement file uploading with behaviour which is commonly seen in various
i starter in jqgrid, i want implement inline edit in jqgrid i have this
given this class definition: public class Frame { IFrameStream CapturedFrom; } I want implement
Microsoft has announce that WindowsLiveID become a OpenID provider . I want implement it
I want to implement a simple script to do some boring housekeeping on my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.