java-me

Interacting with UI threads in Java/J2ME

落爺英雄遲暮 提交于 2019-11-29 07:39:19
I'm writing a J2ME application. One of the pieces is something that polls the contents of a directory periodically, and, if there are any new things, paints them on the screen. I've done this by having the UI form launch a polling thread with a pointer back to itself, and when the polling thread finds something it calls back to the form and calls a syncrhonized method to update it's display. This seems to work fine. The question I have is this. In C#/.NET I know it is not nice to have non-UI threads updating the UI, and the correct way to handle this is to delegate it up to the UI thread. E.g.

Render PDF on a Blackberry?

淺唱寂寞╮ 提交于 2019-11-29 07:32:56
We are using Blackberries to display PDF reports. Here are background details on the problem: The PDF reports are created using JasperReports. Report format can be changed. Different report formats are available (as per the feature set of JasperReports). The PDF reports are on a website, too, so retaining a single source is ideal. The page setup is in Landscape. Here are the issues we have encountered: Users cannot see a full line of text on the Blackberry. The size of the PDF and UI makes reading difficult, at best. The menu option to convert the PDF to text loses too much formatting to be

HTTP authentication in J2ME

自作多情 提交于 2019-11-29 06:59:15
I'm trying to create a J2ME app, which talks to webserver using HttpConnection connector. When I am talking to the WebServer, I have to authenticate using Basic HTTP auth, which normally goes like http://username:password@website.com/rest/api/method But in J2ME, when I construct a url of this form, it doesn't work. I also tried adding request property, hc = (HttpConnection) Connector.open(url); hc.setRequestProperty("User", "alagu"); hc.setRequestProperty("pass", "mypassword"); but didn't work. Has anyone done j2me based HTTP auth before? Thanks in advance. It could be J2ME has no support for

Running J2me apps on Android phones

独自空忆成欢 提交于 2019-11-29 06:35:48
Is it possible to run J2ME apps on Android phones? If so, what is the installation procedure? Otherwise, is it possible to convert .jad files to .apk? In this case, what is the procedure. (I have already tested the procedure offered by netmite but it doesn't seem to work.) Using this site http://www.netmite.com/android/srv/2.0/getapk.php you can convert your J2ME application in to Android Application. You need to just supply your .Jad & .Jar file in it and it will generate Android's executable file .apk for you. However in it doesn't able to convert all the feature of Java ME to Android, but

How to filter an array in Java?

佐手、 提交于 2019-11-29 05:38:06
How can I filter an array in Java? I have an array of objects, for example cars: Class: public class Car{ public int doors; public Car(int d){ this.doors = d; } } Use: Car [] cars = new Cars[4]; cars[0] = new Car(3); cars[1] = new Car(2); cars[2] = new Car(4); cars[3] = new Car(6); Now I want to filter the array of cars, keeping only 4 doors and more: for(int i = 0; i<cars.length; i++){ if(cars[i].doors > 4) //add cars[i] to a new array } } How should I do this? Before I did it with a Vector: Vector subset = new Vector(); for(int i = 0; i<cars.length; i++){ if(cars[i].doors > 4) //add cars[i]

Privileged operations in netbeans mobility

元气小坏坏 提交于 2019-11-29 05:14:32
I'm writing a Java ME app that will use privileged operations such as messaging. By default the user is prompted to confirm each of these operations, but I would like to run it as a background service. Documentation says to request permission in the jad file, I have done so and presume it will work on a device. However I would like to test this on the Netbeans mobility emulator first. I tried signing the app as "trusted" but my emulated execution still prompts the user for permission. michael aubert The MIDP security model needs to be explained in 2 parts: The phone (or the emulator) contains

Java Convert Object[] Array to Vector

不羁岁月 提交于 2019-11-29 03:56:38
What's the best way to convert an Object array to a Vector? JDE < 1.5 public Vector getListElements() { Vector myVector = this.elements; return myVector; } this.elements is an Object[] Thanks, rAyt I should clarify my question My target platform is a blackberry. Collections aren't supported. Array.asList() isn't, either :/ Full Class package CustomElements; import net.rim.device.api.ui.component .*; import net.rim.device.api.collection.util.*; import net.rim.device.api.util.*; import java.util.*; public class ContactsList extends SortedReadableList implements KeywordProvider { // Constructor

How to implement a most-recently-used cache

萝らか妹 提交于 2019-11-29 02:42:02
问题 What would be the best way to implement a most-recently-used cache of objects? Here are the requirements and restrictions... Objects are stored as key/value Object/Object pairs, so the interface would be a bit like Hashtable get/put A call to 'get' would mark that object as the most recently used. At any time, the least recently used object can be purged from the cache. Lookups and purges must be fast (As in Hashtable fast) The number of Objects may be large, so list lookups are not good

How to deal with the most common classes missing on J2ME

只谈情不闲聊 提交于 2019-11-29 02:39:33
问题 I'm trying to code an application which runs un different java platforms like J2SE, J2ME, Android, etc. I already know that I'll have to rewrite most of the UI for each platform, but want to reuse the core logic. Keeping this core portable involves three drawbacks that I know of: Keeping to the old Java 1.4 syntax , not using any of the nice language features of Java 5.0 only using external libraries that are known to work on those platforms (that is: don't use JNI and don't have dependencies

Blackberry: Emoticons in Chat Application

对着背影说爱祢 提交于 2019-11-29 02:36:28
I want to make a chat application where the emoticons are necessary. I was trying to write my own TextBox to handle some unicode caracters and replace them with smiles and emoticons, but that was a hard work to do and I encountered many problems. Then I tried to make a custom font that will have emoticons in it but I found that a font is made in black and white and cannot be colored. I tried then to use different EditFields so when I find a Bitmap I draw it and start a different EditField but that didnt work for several lines and selection problems occured. The best way was to write my own