java-me

How to parse string containing negative number by j2me api?

旧城冷巷雨未停 提交于 2020-01-03 08:24:10
问题 I have a string which has numbers. I have to parse this string and store these numbers in int, float, etc. Accordingly String str = "100,2.0,-100,19.99,0"; I can do it by Integer.parseInt() and Float.parseFloat() after splitting. But I can't do it for negative number. It throws exception java.lang.NumberFormatException . After searching web I couldn't find any solution for this problem. So how can I parse a negative integer from string and store into int using j2me api set? 回答1: There should

Generating a random hex string (of length 50) in Java ME/J2ME

拈花ヽ惹草 提交于 2020-01-03 06:47:08
问题 My app needs to generate a hex string to use as a session ID. Java's SecureRandom doesn't seem to be working ("java/lang/NoClassDefFoundError: java/security/SecureRandom: Cannot create class in system package") I thought of doing something like this: byte[] resBuf = new byte[50]; new Random().nextBytes(resBuf); String resStr = new String(Hex.encode(resBuf)); But the method nextBytes(byte[] bytes) isn't available for some strange reason. Does anyone have a means of generating a random hex

How to add images to the grid view and adding click function to these images?

百般思念 提交于 2020-01-03 04:32:28
问题 public final class gridFieldDemoScreen extends MainScreen { LabelField one, two, three, four, five, six; public gridFieldDemoScreen() { setTitle("gridFieldDemo"); GridFieldManager grid = new GridFieldManager(2, 3, 0); one = new LabelField("ONE"); grid.insert(one, 0); two = new LabelField("TWO"); grid.insert(two , 1); three = new LabelField("THREE"); grid.insert(three, 2); four = new LabelField("FOUR"); grid.insert(four, 3); five = new LabelField("FIVE"); grid.insert(five, 4); six = new

In J2ME, How I obtain reference of all controls of the form to record form's controls state changes?

↘锁芯ラ 提交于 2020-01-03 03:24:08
问题 In my J2ME app, I want show an alert dialog box only when the user changes the state of any controls—that is, when the user uses any of the control of the form and then try to cancel the form without saving typed data. For example among all 5-6 controls of form if the user types in 1-2 textfields and tries to cancel the form without saving that typed data into database. An alert box should then display with the message "Save changes?" with Yes, No command. How to do this? This is my code

How to highlight focused custom buttonfield (ImageButtonField) on Blackberry?

假如想象 提交于 2020-01-03 03:09:07
问题 I made a custom ButtonField class where I have an image as a button. However, I would like to be able to select this image and to know it is selected, either by partially highlighting it or putting a square around it, whatever. I have a BitmapField in my UI that highlights itself in blue when I select it, but my other images that use ImageButtonField, do not have the blue highlight. I do not want the bitmap to disappear completely when selected. here is the code : package mypackage; import

Text to Speech in j2me

隐身守侯 提交于 2020-01-03 03:06:05
问题 Anyone know of a good text-to-speech solution for j2me? I know it's not officially supported by any devices or in any JSR, but wondering if there are any free libraries that can do it? What about some kind of integration between j2me and python to allow this to happen? I need to add this to a big j2me application, so re-writing the whole thing python is not an option. 回答1: From here: http://en.allexperts.com/q/Java-1046/2008/12/J2ME-text-speech.htm There is a standard Java API for speech

Find application mode, is it idle or not, in Java ME

跟風遠走 提交于 2020-01-03 01:23:24
问题 I want to send stored RMS data using an HTTP connection when the application is in idle mode. So if the user is not doing anything with the application at that time, my thread will invoke and send RMS data to server. For this requirement, how do I how find out if the application in active mode or idle mode? 回答1: You could wait for the backlight to go off, if that's enough of an indication of whether the application is active. Implement the SystemListener2 interface, there's a method

Java Me platform issues in NetBeans

懵懂的女人 提交于 2020-01-02 07:37:35
问题 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

Reading UTF8 strings from a server through http using MIDP

瘦欲@ 提交于 2020-01-02 04:56:09
问题 I want to read UTF-8 strings from a server that I have control of, using java MIDP. My server is sending UTF-8 data. The following code gets close: c = (StreamConnection) Connector.open( myServer, Connector.READ_WRITE); InputStream is = c.openInputStream(); StringBuffer sb = new StringBuffer(); int ch; while((ch = is.read()) != -1) sb.append((char)ch + "->" + ch + "\n"); I print the char and its code to debugging purposes. I think it is reading ASCII chars here, so, when I have some char that

SQLite for BlackBerry

℡╲_俬逩灬. 提交于 2020-01-01 14:39:43
问题 Is SQLite available for BlackBerry ? Is any other Database option available other than SQLite ? 回答1: SQLite has been shipped in Blackberry 5.0; here is the link: http://docs.blackberry.com/en/developers/deliverables/8682/SQLite_overview_701956_11.jsp 回答2: SQLite is scheduled to be released in the next version of the BlackBerry device software, no idea when that will be. Think they were scheduled to announce at hte recent WES event. You could try using Sybase SQL Anwhere as it's available for