java-me

Negative Array Size Exception

廉价感情. 提交于 2019-12-06 04:13:21
问题 I'm new to Blackberry and I'm trying to get post a search term to a server in xml. But I keep getting this error Request Failed. Reason Java.lang.NegativeArraySizeException . I wanted to check if the connection works before I parse the data so from this connection, am expecting to receive the response text in xml. Below is the code: public void webPost(String word) { word = encode (word); String responseText; try{ HttpConnection connection = (HttpConnection)Connector.open("http://some url.xml

Converting the “America/Los Angeles” time zone to “PST” or “PDT” in Java ME

穿精又带淫゛_ 提交于 2019-12-06 02:58:46
问题 My server sends me time zones of the format "America/Los Angeles". On the client, I have a time that I need to display in that time zone. The answer will be "PST" or "PDT", depending on daylight savings at the given time. How do I do that conversion? I'm on Java ME (Blackberry 4.7, to be accurate), so I can't use Joda Time. I will need to make this calculation rapidly for a lot of dates (but only one time zone), so I can't just have the server send me an offset, because the offset might

JavaME - LWUIT images eat up all the memory

梦想与她 提交于 2019-12-06 01:33:09
问题 I'm writing a MIDlet using LWUIT and images seem to eat up incredible amounts of memory. All the images I use are PNGs and are packed inside the JAR file. I load them using the standard Image.createImage(URL) method. The application has a number of forms and each has a couple of labels an buttons, however I am fairly certain that only the active form is kept in memory (I know it isn't very trustworthy, but Runtime.freeMemory() seems to confirm this). The application has worked well in 240x320

how to use the HTTP range header in J2ME?

别来无恙 提交于 2019-12-06 00:23:19
is it possible to use range header in HTTP with HTTP GET request? if yes than how? I just want to download bytes from server with specified bytes. i.e if I want to download bytes from 0 to 255. See this sample code, HttpConnection connection = null; InputStream inputstream = null; try { connection = (HttpConnection) Connector.open(url); // Enter your URL here. //HTTP Request connection.setRequestMethod(HttpConnection.GET); connection.setRequestProperty("Content-Type","//text plain"); connection.setRequestProperty("Connection", "close"); // HTTP Response System.out.println("Status Line Code: "

Using boolean var for stopping threads

淺唱寂寞╮ 提交于 2019-12-05 21:52:41
I have a Java book I'm learning from and in one of the examples, I saw something suspicious. public class ThreadExample extends MIDlet { boolean threadsRunning = true; // Flag stopping the threads ThreadTest thr1; ThreadTest thr2; private class ThreadTest extends Thread { int loops; public ThreadTest(int waitingTime) { loops = waitTime; } public void run() { for (int i = 1; i <= loops; i++) { if (threadsRunning != true) { // here threadsRunning is tested return; } try { Thread.sleep(1000); } catch(InterruptedException e) { System.out.println(e); } } } } public ThreadExample() { thr1 = new

Java Me platform issues in NetBeans

泄露秘密 提交于 2019-12-05 20:40:00
I have installed Netbeans 8.0 that comes with pre installed Java ME plugin. Now when I tried to create a new Java ME project it said No Java ME Platform found. Please add at least one Also, the field "Java ME platform" was blank. So I clicked on Manage platforms and added Java ME CDLC Emulator Platform and gave the path to JAVA ME SDK. It discovered the platform and added the devices. After doing this, the field "Java ME platform" is still blank and I'm not able to select the Java Me platform. Please help! Had the same problem during installation on a new PC. I'm developing for J2ME, CLDC 1.1,

Open file with MIDlet.platformRequest()

半腔热情 提交于 2019-12-05 19:38:53
Is it possible to get a device to open a file on disk using the MIDlet.platformRequest(String url) method? I was hoping to use the following: midlet.platformRequest("file:///path/to/file/file.png"); But this just throws a ConnectionNotFoun d exception. I'm specifically using the BlackBerry platform, but I do not have access to the proprietary BlackBerry API. File could be of any type, so obviously I'm not expecting it to handle every one. Cheers No, it is not possible to open arbitrary files using platform request. MIDP 2.0 requires devices to support platform request only for URL and tel:

MIDP 2.0 version issues: $method is undefined for $type

为君一笑 提交于 2019-12-05 17:39:19
I've written a MIDlet that does several "advanced" things: fetching images from the web, resizing them, saving them on the phone, displaying them. This all works perfectly in the Nokia S60 3rd Edition FP1 emulator. This device has MIDP 2.0 and CLDC 1.1 support (also JSR75, which I need in order to save files). It also works as it should on the Nokia E71 (physical device). I then tried to run the MIDlet on several other emulators. One of them, the DefaultCldcJtwiPhone2 from the Java ME SDK 3.0, also claims MIDP 2.0 and CLDC 1.1 support. It doesn't have JSR75, which explains why "FileConnection

J2ME like Sprite on Android

旧巷老猫 提交于 2019-12-05 16:45:00
For my useless project of the month I'm working on a 'emulator' to run J2ME programs on Android. But now I'm stuck with the J2ME Sprite implementation. Specifically the transformations used in it. In my Sprite I have a bitmap with three character images. I would like to paint the second frame mirrored or rotated 90 degrees. What would be the best way for it? I have following code that paints the given frame without any transformations. frameX, frameY are frame position coordinates on give sprite bitmap. Rect src = new Rect(frameX, frameY, frameX + spriteWidth, frameY + spriteHeight); Rect dst

Is HTTP PUT supported in J2ME?

心已入冬 提交于 2019-12-05 16:23:17
I just noticed a strange thing in MIDP 2.0 API: The HttpConnection class apidocs make explicit references to methods GET, POST and HEAD, but no other methods. Does this mean that they are not supported? http://java.sun.com/javame/reference/apis/jsr118/javax/microedition/io/HttpConnection.html I also tried checking the MIDP 2.0 spec, but couldn't find any hard facts about this. I can give this a try on some phone(s), but can't try them all. Does anyone know which HTTP methods are required to be supported by phones implementing the MIDP 2.0 spec? Or any experience in finding phones that support