How do I change a Java ME device System time? - java-me

I'm developing an application that needs to synchronize the time on a server with the time on the device.
Blackberry devices have the net.rim.device.api.system.Device.setDateTime(long dateTimeMillis) method for this. I'm looking for something similar in Java ME devices.
I can live with manufacturer specific APIs - specialy nokia, sony ericsson and motorola ones, and most JSRs.
Does anyone know if there is any way to do this?

Most manufacturers, such as Nokia, don't have that functionality in Java. You may need to take a look into Symbian C++ and other platform specific development tools.

You can't do with Java-me for some security reasons. So you can't change the internal time of system. You can possible to get the current time only.

Related

Can I create a custom android OS?

I currently have an old Galaxy Trend Lite GT S7390 that is so old it's virtually unusable. I want to give it the funtionality of an old mp3 player, but since it has wifi functionality, I thought it would be cool to have an OS that would allow it to work with the Spotify app, however that's ALL I want it to do. I just want it to work with Spotify.
Is this possible? I'm perfectly fine figuring out how to do it, I just need to know if it's technically possible and a direction to begin at.
I haven't tried much yet.
Android is open source. You can modify it how ever you want. You can flash it to any device (support withstanding). But will it support your all your device's specific cheap Chinese hardware? Likely not. You'll probably have to write modules to integrate your specific hardware drivers. That' why most Android phone makers give their own version of Android. However, they have to pay licensing to Google because they are charging you for it. As long as you don't charge for your resulting product, you do not have pay licensing.
Android is written in Java. Here's a link to the project:
https://source.android.com/
I hope your computer can handle running Android Studio. It's a hungry, hungry resource monster.

how to turn Bluetooth on/off with J2ME?

I want to write a program in J2ME to turn the Bluetooth on/off automaticly in a certain time without the user permission.
I'v been looking for a while but I couldn't find an answer.
Some phones will automatically switch bluetooth ON when a MIDlet starts using the Java ME Bluetooth API.
Other phones will not.
AFAIK, there is no Java ME API to switch bluetooth ON/OFF.
I have yet to find a mobile phone that automatically switches bluetooth OFF after some time of inactivity.
Any way you find to do this (I'm sure it's doable in Symbian OS C++, for example) will be platform-dependant.
There is definitely no way to programmatically switch your Bluetooth on and off in Java ME. However what may be useful is to switch between discoverable modes:
LocalDevice.getLocalDevice().setDiscoverable(DiscoveryAgent.GIAC);
to be discoverable, and
LocalDevice.getLocalDevice().setDiscoverable(DiscoveryAgent.NOT_DISCOVERABLE);
to hide from other devices. It doesn't save battery, but it does make things that little bit more secure I guess.
No way. We cannot be able to automatically turn on/off bluetooth in java & j2me. Better you refer to the documentation of JSR 82

Develop applications to mobiles

I have very easy question, but I simply have any idea of the answer.
I have developed a small mobile-application using java, for my nokia.
The problem is that when installed on my samsung the application simply crashed.
Then I tried on my other nokia but different model, and I didn't got the normal behavior.
So my question is, does anyone have any idea how companies that develop mobiles applications/games test their software.
Does they have to have all models for all mobiles phones??
Companies that target many phones in many countries usually only let you install the application on your phone if they recognise your handset User Agent in the HTTP headers of the request to download the .jad or .jar file.
There are multiple ways to test an application on many handsets for many mobile network operators.
From simply buying the phones, to establishing commercial parternships with handset manufacturers and mobile network operators, to having a Device Anywhere account.
I don't know if you need all models of all phones. But you will definitely need separate test (and probably different builds) for different phones regarding:
MIDP version
Screen Size
Input Devices
Speed & Memory
Java, in this case is, WOTA (Write Once Test Anywhere) instead of WORA (Write Once Run Anywhere). :-)
Phone specs and Java implementations vary a lot, but within each manufacturers range there will be groups of phones that share the same specs and implementation.
I used to work at a company making J2ME games, what we did there was test on every handset we released the game on, but we had 2 types of test - Complete and Compatability.
We would adapt a version of the game for a specific phone, eg Sony Erricson K800i, and have it thoroughly tested according to the Complete Test spec.
Once that had passed, we then used that build on phone known to have similar specs and good previous compatability with other games (we kept a database of specs and compatability records), eg Sony Erricson W910i, and submit it for a compatability test, which was a bit less thorough and a bit quicker.
Once you've been doing it a while you get to know the capabilities of phones and which phones you could use the same build on, but there is often a bit of guesswork involved :) Sometimes you get matches you wouldn't expect, and sometimes a match you would expect to work doesn't.
Edit: I was going to post this as a comment, but I can't (because i'm an SO noob :), out of interest, what phones are your Nokia's and Samsung?
I can't remember many specific handset names, but here is a quick rundown of compatability across manufacturers:
Sony Erricsons are generally excellent - if it works on one, it will likely work on all SE handsets with the same resolution.
Nokia's are generally good within a certain smaller group eg N95 builds work well on most nokias with the same res that were released after the N95, but some handsets are a bit of a pain.
Samsungs are pretty bad - the J2ME implementation on most is flawed (Hide/Show Notify methods not being called is an example), and the memory and speed are typicly a bit crap.
Motorola phones are not great, but are generally quite compatable with oneanother. Same goes for LG, although their more recent models are much better.
Testing is one of the most labour intensive part of mobile phone development. Typically a company might simply buy a lot of different phones to test on for real, or target a particular subset such only as Series 40 Nokia phones.
But alternatives exist out there where you can remotely deploy your app to phones, such as Nokia's Remote Device Access Services.
One way that might limit the problems is to target J2ME MSA (Mobile Service Architecture) compliant phones, where MSA attempts to reduce variations in vendor implementations of J2ME.

Which mobile operating systems support J2ME?

I've been tasked with using WURFUL to determine whether or not a mobile browser is capable of downloading a J2ME app developed by my company.
I first thought I could use the "device_os" tag and filter by that, however, I'm unsure what the complete list of J2ME OS's are... any ideas?
I've been told there are no MIDP requirements, and that the application will run on any J2ME-supported handset (with two specific resolutions, which I already know how to query)
Thanks in advance.
There is no way to know all the OSes that support J2ME. Mainly because most feature handset comes with a proprietary OS which probably you have never seen before. It is a better idea try to identify the handset model and decide if it supports J2ME or not.
Another thing is, you may want to know which JSRs are supported by a specific handset. I do not know your application but probably you are using some optional JSRs that are not supported by some handsets although they have basic J2ME support.
Java ME SDK 3.0 includes a database of supported devices. Also there are other web sites that provides these kind of information. One example to those would be this J2ME Handsets web site.
If you are fine with just covering a large range of phones, you should include Symbian S60, S40, Windows Mobile, Blackberry and Android.
Symbian
Win Mob
Android
Almost every Sonyericsson phones
IMHO you don't have to worry about how many handsets support j2me because majority of the phones support it.
At least Symbian and Android.

Midlet wake up from bluetooth connection

I'm trying to register a midlet for push registration, in order to wake up from a bluetooth connection.
The requested behavior is that the application will wake up when a car's kit (hands free) will be in the range of the device.
Is it possible at all?
If yes, how should it be done?
Thanks in advance,
I can confirm that it is possible to wakeup a MIDlet in Nokia Devices trough a registered service in the push-registry.
The registration can be defined in the JAD (static registration) or dynamically in the code.
Nokia phones S60 3ed and up and S40 3ed should support this functionality, on other phones (sony,samsung,motorola etc..) I didn't find this feature working.
Google this JAD attribute: MIDlet-Push-1
Good luck!
I don't think it's possible to start up a midlet when it comes into range of a device, even with Bluetooth push registry compatibility (were you to find a handset supporting it).
Your best bet might be to have a midlet running in the background, constantly checking which devices are in the vicinity. When it discovers your hands-free kit, you could bring it to the foreground (if the handset supports it; this is usually achieved by Display.setCurrent(null) for background, and Display.setCurrent(<Displayable instance>) for foreground).
JSR 82 provides the functionality you need.
Beware though, this constant Bluetooth polling will drain the device's battery!
This is advanced stuff. Nice.
While this can be available on mobile phones according to the JSR-118 and JSR-82 specifications, I suspect not many handset manufacturers have actually implemented it.
Symbian provided a TCK-compliant reference implementation for Java BlueTooth Push to its licensees but testing it is a nightmare and I don't know whether either Nokia, Motorola or Sony-Ericsson actually included the functionality in a phone.
My best guess of Symbian phones to try this on: Nokia N95, Sony-Ericsson P990 or W960, Motorola Z8. I would also advise trying on as recent a Bluetooth-enabled non Symbian Sony-Ericsson phone as you can find.
If you find a handset specification that actually says it supports J2ME BT Push, you then need to check whether that is supposed to work using RFComm, L2CAP or both. I don't know what your car kit uses.
As far as writing Java code to use Bt push, you can start by reading the example code in the 2 JSRs and the J2ME SDK from Sun Ltd.

Resources