01-05-2009 03:35 AM
Solved! Go to Solution.
01-05-2009 04:20 AM
I think this KB article will answer your question.
How To - Alert a user from a Background application
Article Number: DB-00407
01-05-2009 04:52 AM
01-29-2009 11:22 AM
In the last sentence of that linked article (just before the code block) it says "background application that extends UiApplication." I'm wondering if it shouldn't say "background application that extends Application." I mean, if your app extends UiApplication can't it just use UiApplication.pushModalScreen(), etc.? Or is the advantage of the suggested code that it gets around the problem of the app automatically exiting when the dialog is popped off the screen stack?
01-29-2009 03:51 PM
This article is out of date.
Don't use UiEngine.queueStatus(). It has been deprecated since about 4.1.
Use UiApplication.pushGlobalScreen(). You should place the push in a Runnable and pass this to UiApplication.pushGlobalScreen(), if you extend UiApplication.
If you extend Application, then get a reference to the UiEngine and call its pushGlobalScreen().
01-30-2009 06:09 AM
01-30-2009 07:37 AM - edited 01-30-2009 07:47 AM
private void notifyUser(String data) {
UiEngine ui = Ui.getUiEngine();
Screen screen = new Dialog(Dialog.D_OK, data, Dialog.OK, Bitmap.getPredefinedBitmap(Bitmap.EXCLAMATION), Manager.VERTICAL_SCROLL);
//ui.queueStatus(screen, 1, true);
ui.pushGlobalScreen(screen, 1,UiEngine.GLOBAL_QUEUE);
}
public void locationUpdated(LocationProvider provider, Location location) {
/**
* Display the location fix if the fix is valid.
* Otherwise, display an error message.
*/
if ((location != null) && location.isValid()) {
QualifiedCoordinates coordinates = location.getQualifiedCoordinates();
if (past_coor != null) {
_distance = coordinates.distance(past_coor);
_distance = (double)(int)((_distance+0.005)*100.0)/100.0;
}
past_coor.setLongitude(coordinates.getLongitude());
past_coor.setLatitude(coordinates.getLatitude());
if (_distance > _accuracy) {
if ((coordinates.getLongitude() != 0) || (coordinates.getLatitude() != 0)) {
_url = "http://" + _host + "/gps/proc.asp?imei=" + _deviceID + "&lon=" + coordinates.getLongitude()
+ "&lat=" + coordinates.getLatitude();
try {
getViaStreamConnection(_url);
notifyUser("Send OK!");
} catch (IOException e) { notifyUser("Error: Network error"); }
} else{ notifyUser("Error: Coordinate was 0"); }
}
} else{ notifyUser("Error: Location invalid"); }
}
too bad it can't run now, did i make something wrong?
01-30-2009 09:06 AM
01-30-2009 09:07 AM
04-19-2010 05:30 PM
Hello,
I tried it too. But I didn't get it working.
Here is my code:
Application.getApplication().invokeLater(new Runnable() {
public void run() {
UiEngine ui = Ui.getUiEngine();
Screen screen = new Dialog(Dialog.D_OK, "Look out!!!",
Dialog.OK, Bitmap.getPredefinedBitmap(Bitmap.EXCLAMATION),
Manager.VERTICAL_SCROLL);
ui.pushGlobalScreen(screen, 1, UiEngine.GLOBAL_QUEUE);
}
});
I use a background application, which starts a new thread. In this thread you will find the code above.
Why doesn't work it for me?
Thanks for any answer.