java-me

Java (Eclipse) - Conditional compilation

家住魔仙堡 提交于 2019-12-04 13:16:27
问题 I have a java project that is referenced in j2me project and in android project. In this project i would like to use conditional compilation. Something like... //#if android ... //#endif //if j2me ... //#endif I have been reading about this but i did not find anything useful yet. 回答1: You could use Antenna (there is a plugin for Eclipse, and you can use it with the Ant build system). I'm using it in my projects in a way you've described and it works perfectly :) EDIT: here is the example

SQLite for BlackBerry

倾然丶 夕夏残阳落幕 提交于 2019-12-04 13:09:32
Is SQLite available for BlackBerry ? Is any other Database option available other than SQLite ? 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 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 Blackberry. SQLite is available as of BlackBerry OS version 5.0. Here's the link for more information: http:/

Convert java 5 code using generics to code that can run on a J2ME device?

。_饼干妹妹 提交于 2019-12-04 13:01:57
Are there any solutions or tools that transform java 5 code that uses all the new java 5 features(generics, autoboxing, varargs, static imports) into code that can run on a J2ME device? I am particularly interested in handling generics - the other features are nice to have but not mandatory. I need source code as the result of this conversion as this will be compiled using a custom compiler. (I cannot use bytecode manipulation(ala retroweaver)) Compiling with the regular javac and targeting an older JVM will give you proper bytecode for generics at least. If you really need source it's

J2ME - number format

╄→尐↘猪︶ㄣ 提交于 2019-12-04 11:41:38
I need to format decimal numbers with patterns in J2ME just like java DecimalFormat . I see an option to port Format / NumberFormat / DecimalFormat . Can you suggest ready to use implementation or library? Thanks! So, I've manage to port desktop java implementation: bbnumberformat : String[] patterns = new String[] { "#,#00.00#", "0.0;(0.0)", "0.###E0" }; DecimalFormat format = (DecimalFormat) DecimalFormat .getNumberInstance(); double value = -12.321; for (int i = 0; i < patterns.length; i++) { String pattern = patterns[i]; format.applyPattern(pattern); String text = "Pattern: " + pattern + "

Negative Array Size Exception

喜你入骨 提交于 2019-12-04 11:28:58
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"); connection.setRequestMethod(HttpConnection.POST); connection.setRequestProperty("Content-Type",

Shared Library for iPhone and BlackBerry

空扰寡人 提交于 2019-12-04 11:10:39
I have a set of functionality (classes) that I would like to share with an application I'm building for the iPhone and for the Blackberry (Java). Does anyone have any best practices on doing this? This is not going to be possible as far as I understand your question - the binary format for the iPhone and Java are not compatible - and even for a native library on a blackberry device. This is not like building for OS X where you can use Java unfornately the iPhone doesn't support Java. The best idea is probably to build you library in Objective-C and then port it to Java which is an easier

Can't access/read SIM phonebook in Nokia

不想你离开。 提交于 2019-12-04 10:24:40
am trying to access both the Phone's phonebook and SIM phonenook on Nokia 5130c-2 XpressMusic. The app runs without errors but it only returns the numbers from the phone's Phonebook. When I list the available phonebooks using this code String[] all_contact_lists=PIM.getInstance().listPIMLists(PIM.CONTACT_LIST); it gives me both the Phonebook and SIM card lists. i.e 1. Phone 2. SIM I have tried explicitly reading from the SIM card using this code but it still returns nothing(even though I have numbers saved in the SIM card.) Code: ContactList clist = (ContactList) PIM.getInstance().openPIMList

How can I add a REGEX match to my J2ME project?

随声附和 提交于 2019-12-04 09:06:27
The question pretty much sums it up. Just want to run a regular expression match on a string in J2ME. JRegex will not run on CLDC device. Try this one: code.google.com/p/regexp-me/ . Will JRegex run in J2ME? UPDATE: Based on Rory's comment, I recommend JRegex, then. JRegex doesn't compile on J2ME (at least in the blackberry dev environment). I'm interested in a regex library as well but JRegex doesn't seem to work for this purpose. It's hard to tell what runs on J2ME due to the extreme old age of J2ME's API support, but try Apache ORO . That's sufficiently old, crusty and obsolete that it may

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

左心房为你撑大大i 提交于 2019-12-04 08:15:25
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 change depending on the date. Edit: Let me restate the problem, because there seems to be some confusion. I

J2ME Soft Key Wrapper

你离开我真会死。 提交于 2019-12-04 07:42:22
Reading some articles, told me that soft keys varies between devices. Some says -6 or -21 for left soft key and -7 or -22 for right soft key. Given this situation, is there any good wrapper or function or best practice to handle it properly? If not possible for ALL devices, what is the best way to support most devices? with minor or no hack at all? To give you a feel for the scope of the problem have a look at this table of keycodes. Omermuhammed's approach is a good one if you are able to vary the JAD content depending on the target handset, for example by looking at the user-agent header