back button in lwuit with blackberry - blackberry

I developed an mobile application using LWUIT and it works fine in devices with J2ME.
I want to run the same application in Blackberry also.
I saw some samples about LWUIT on Blackberry but none of them answered me.
How can I handle the back button on the device to make back movements?
What I mean is that, when I press the back button on the device, I want the application move to the previous screen.
I used regular buttons to handle back movements just for now, but when we think of user side, it is not so friendly.
I dont want to use commands like I did in j2ME app., because it seems not so nice.
Is there anyone who can solve it?

Set a particular back command to the form. For example,
Command backCmd = new Command("Back"){
public void actionPerformed(ActionEvent evt) {
previousForm.show();
}
};
currentForm.setBackCommand(backCmd);

Related

How to prevent reload on Tizen Public Preview Deeplink?

I'm writing a web app for Tizen Smart TV. One of the required features is implementing the Smarthub Public Preview deeplinking.
I have setup the app to open at a specific content when the Public preview tile is clicked. However, I cannot prevent the app to reload. The documentation mentions adding the appcontrol event to the window event listeners, but I don't think this event is being recognized by the app, since the code is not executed.
It only works if I directly add my deeplink() method to the onload property.
According to documentation, this piece of code should prevent the app to reload, but it is not working:
<tizen:app-control>
<tizen:src name='index.html' reload='disable'></tizen:src>
<tizen:operation name='http://samsung.com/appcontrol/operation/eden_resume'></tizen:operation>
</tizen:app-control>
window eventListener is not working wither:
onload="window.addEventListener('appcontrol', deepLink)"
Any help on how to implement this correctly?
Thank you in advance
You are probably modyfing window.location in the app (ie in router).
reload='disable' prevents reloading index.html. When application receives app control request and page is different, application will be reloaded.
You can find more about appcontrol in Tizen documentation (note that Tizen for TV may differ from other devices):
https://docs.tizen.org/application/web/guides/app-management/app-controls/
I've got some information regarding your question.
To do application resume without Page reload,
Set extra data in app-control like below
key: SkipReload
value: Yes

Blackberry 10 launch wifi settings page programmatically

In my blackberry 10 (QNX, Cascades) application I have to launch WIFI setting page programmatically. I google it but having no luck.
Please help me to find out is it possible in Blackberry 10 or not.
You're right, it's undocumented and you won't find any information on Google. Here's how to do it :
bb::system::InvokeRequest request;
request.setUri("settings://wifi");
bb::system::InvokeManager manager;
manager.invoke(request);
The magic string is settings://wifi, you can try it right inside your BlackBerry 10 browser to see where it will send you, just note that the BlackBerry 10 browser will have an additional popup asking if you want to open the URI, this popup won't show in your application it will open the Settings app as a card at the Wi-Fi page directly. User can then just dismiss the card to get back to your app.

Load web page in PhoneGap app

I'm using PhoneGap with AngularJS framework.
I want to display a web page. I tried to use iframe but scroll isn't working.
I want to keep this page inside my app and not as a in app browser or external browser.
My app is running on iOS, Android and WP8 both.
Some help please :)
Thanks in advance
function loadWebView(pid)
{
var url = "http://dummysite.com/index.php/catalog/product/view/id/"+pid;
$("#div_load_page").html('<object data='+url+' class="webview"/>');
};
This is simple jQuery I've applied in my phonegap application which gives me the desired result. Scroll bars are visible and depend on site's responsiveness and size.
See Result.

How to launch AppWorld from an application? [BlackBerry]

This might be a easy question but i couldn't find solution. I want to open AppWorld by clicking a button in my BB application. For example when user clicks this button Appworld will show "Facebook Application" page. Can i do this?
In Android platform this line launches GooglePlay for Facebook App. Does BlackBerry supports this kind of method?
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=com.facebook.katana")));
Here is a simple way to do this:
Browser.getDefaultSession().displayPage("http://appworld.blackberry.com/webstore/content/2360/?lang=en");
Above code will invoke the browser in the application and open the BlackBerry App World, I tested it in device and it's perfectly working. For now I put a Whats App messenger link, but you can customize the link according to your requirement.
You can open App World from your BB application directly using the following code. This code avoids opening the browser first.
Registry registry = Registry.getRegistry(this.getClass().getName());
Invocation invocation = new Invocation(null, null,
"net.rim.bb.appworld.Content",
false, ContentHandler.ACTION_OPEN);
invocation.setArgs(new String[] { /* app id in appworld */ });
registry.invoke(invocation);

How to keep phonegap application open when pressing back button in blackberry

I'm building a phonegap application for my blackberry. When I have the application open and I press the back button, the application terminates entirely, instead of just being "minimized" and allowed to sit in memory. So next time I click on the application, I have to login instead of seeing the last page I was on.
Is there a way to cause the blackberry back button to "minimize" instead of complete termination?
For BlackBerry Java applications the 'Hang Up' button is the standard UI request to minimize the application. Try that first. You should only override the function of the back button to minimize instead of exit if the application cannot or should not cleanly exit.
One of the most annoying behaviors for applications is if they don't exit when requested.
There are a few onEvents that are provided by Blackberry's api to essentially background the application when someone tries to pop the screen off the display stack. It's been a while since I've done this but I have done this personally. I believe I used onObscured.. reference: http://www.blackberry.com/developers/docs/4.2api/net/rim/device/api/ui/Screen.html#onObscured()
There are other events on there just carefully read through the api and instead of this.close() the screen do something like UiApplication.getUiApplication().requestBackground();
I have few more observations. Back button exits the application only on 6.0 (OS) phones. But it doesn't exit on 7.0 phones.
In order to avoid issue on 6.0 ,You can over ride the back button functionality in your .js file with below code.
blackberry.system.event.onHardwareKey(blackberry.system.event.KEY_BACK,function() {
//keep your code here
alert("back key pressed");
//For example..
//if you want to navigate to particular page(say previous.html) on back button,you can use
window.location.replace("previous.html");
//you can also use
history.back(); // To navigate to previous page as per page navigation.
return false;
});
To get this event in your .js file you need to add below line in your config.xml
<feature id="blackberry.system.event" required="true" version="1.0.0.0"/>

Resources