Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
New Developer
Posts: 13
Registered: ‎02-17-2012
My Device: 9860, 9900, playbook
My Carrier: Telenor (Sweden)

Back button doesn't work in an invoked or launched app

In my app I wan't to share some info. So I'm using invoke to start the email app and launch to start the sms app. The problem is that after the apps are started the back button doesn't seem to work as I expect. When I press back nothing happens in the started app (sms/email) but it seems like the back button presses are stacked for when I return to my app. When I close the started app (sms/email) via the blackberry button menu, I get returned to my app (as I expect) but now all the back button presses gets executed.

 

The behaviour I would like to have is that when I press back in sms/email, I get returned to my app, i.e. the same behaviour as the "Close" option in the blackberry button menu.

 

The commands I'm using are:

//sms

blackberry.launch.newSMS({ "number":"123456789", "text" : "message" });

 

//email

 
var args = new blackberry.invoke.MessageArguments('foo@domain.com', 'hello', 'world');
args.view = blackberry.invoke.MessageArguments.VIEW_NEW; // New
blackberry.invoke.invoke(blackberry.invoke.APP_MESSAGES, args);  // New Message

 

 

 

Retired
Posts: 1,561
Registered: ‎04-12-2010
My Device: BlackBerry Z10
My Carrier: Bell

Re: Back button doesn't work in an invoked or launched app

Hello henrik,

 

Can you confirm the device model and OS version that you are testing on? Ideally the full OS version (i.e. 6.0.0.123) which can be viewed in the device options.

 

In my experience, the back button has worked in the way you describe you want it to work; specifically pressing the back button will close the invoked application. I have a feeling this might be an OS-specific bug, but would like to test it out just to confirm.

 

Erik Oros

BlackBerry Development Advisor


Erik Oros | @WaterlooErik | eoros@blackberry.com | Developer Issue Tracker

If a reply has answered your question, please click Accept as Solution to help other visitors in the future.
New Developer
Posts: 13
Registered: ‎02-17-2012
My Device: 9860, 9900, playbook
My Carrier: Telenor (Sweden)

Re: Back button doesn't work in an invoked or launched app

Hi!

 

I've tested on three phones:

  • BlackBerry Bold 9900 (v 7.0.0.585, Platform 5.0.0.734)
  • BlackBerry Torch 9810 (v 7.0.0.585, Platform 5.0.0.734)
  • BlackBerry Torch 9860 (v 7.0.0.576, Platform 5.0.0.733)

Thanks for looking into it.

 

/H

Retired
Posts: 1,561
Registered: ‎04-12-2010
My Device: BlackBerry Z10
My Carrier: Bell

Re: Back button doesn't work in an invoked or launched app

Hello henrik,

 

Are you by chance overriding the default behaviour of the back button within your application at all? I've tested a small sample and am getting the expected (i.e. good) behaviour. My files look like so:

 

config.xml


<?xml version="1.0" encoding="utf-8"?>
<widget xmlns="http://www.w3.org/ns/widgets" xmlns:rim="http://www.blackberry.com/ns/widgets" version="1.0.0">

	<name>Sandbox</name>
	<author>Oros</author>
	
	<content src="index.html"/>
	
	<feature id="blackberry.invoke" />
	<feature id="blackberry.invoke.MessageArguments" />
	<feature id="blackberry.message" />
	
</widget>

 

index.html


<!DOCTYPE html>
<html>
	<head>
	</head>
	<body>
	
		Hello World
		
		<script type="text/javascript">
			
			function ready() {
				var args = new blackberry.invoke.MessageArguments('foo@domain.com', 'hello', 'world');
				args.view = blackberry.invoke.MessageArguments.VIEW_NEW;
				blackberry.invoke.invoke(blackberry.invoke.APP_MESSAGES, args);
			}
			
			document.addEventListener("DOMContentLoaded", ready, false);
			
		</script>
	
	</body>
</html>

 

config.xml and index.html were built off your sample / the documentation here:

https://bdsc.webapps.blackberry.com/html5/apis/blackberry.invoke.MessageArguments.html

 

In my test, after I launch the application and the DOMContentLoaded event is triggered, a new email message is displayed with the preset values. If I hit the  button, I am returned to the sample application on the first click.

 

Could you give the above sample a try and let me know if you're still seeing the same issue?

 

Erik Oros

BlackBerry Development Advisor


Erik Oros | @WaterlooErik | eoros@blackberry.com | Developer Issue Tracker

If a reply has answered your question, please click Accept as Solution to help other visitors in the future.
New Developer
Posts: 13
Registered: ‎02-17-2012
My Device: 9860, 9900, playbook
My Carrier: Telenor (Sweden)

Re: Back button doesn't work in an invoked or launched app

Thanks for the code sample.

 

Yes your code sample works on my 9900.

 

I'm not overriding the back button beaviour in the app, at least no intentionally. I DONT'T use anything like this:

blackberry.system.event.onHardwareKey(blackberry.system.event.KEY_BACK, handleBack);
Retired
Posts: 1,561
Registered: ‎04-12-2010
My Device: BlackBerry Z10
My Carrier: Bell

Re: Back button doesn't work in an invoked or launched app

Hello henrik,

 

Thanks for the additional info. I would have been surprised if something like that were at the root since really it should only apply to key presses within your application, but I wanted to check just in case. And if you're not using code like that then we can rule that possibilty out.

 

In my sample, I invoked the messages application on the DOMContentLoaded event, can you confirm how you are triggering your invoke? (i.e. Another event, button click, <a> clicked, etc.) Could you provide the relevant source for this invoke?

 

Also, in your invoke method, are you doing anything other than invoking the messages application? (i.e. displaying any alerts, try/catch, calling other functions, etc.)

 

In all honesty I'm not sure what would cause this, but perhaps by taking a look at the circumstances and code surrounding the invoke, we'll be able to identify the cause.

 

Erik Oros

BlackBerry Development Advisor


Erik Oros | @WaterlooErik | eoros@blackberry.com | Developer Issue Tracker

If a reply has answered your question, please click Accept as Solution to help other visitors in the future.
New Developer
Posts: 13
Registered: ‎02-17-2012
My Device: 9860, 9900, playbook
My Carrier: Telenor (Sweden)

Re: Back button doesn't work in an invoked or launched app

Hi!

 

Really appreciate you looking into this. I'm sorry for my late reply.

 

Here's the part of the code where I do my launch/invokes. I've modified it just a little bit to remove some api:s I'm using, but this is basically it. I'm also using bbui.js in the app. 

 

try {
if ((window.blackberry === undefined) || (blackberry.ui.dialog === undefined)) {
return false;
}
var selection = ["SMS", "E-Mail", "Facebook", "Twitter", "Abort"];
var ret = blackberry.ui.dialog.customAsk("Share", selection, 4, true);

if (ret == 0) {
//SMS
blackberry.launch.newSMS({ "number":"", "text":"Some text" });
} else if (ret == 1) {
//EMAIL
var args = new blackberry.invoke.MessageArguments('', progTitle, 'Some text');
args.view = blackberry.invoke.MessageArguments.VIEW_NEW;

blackberry.invoke.invoke(blackberry.invoke.APP_MESSAGES, args);
} else if (ret == 2 || ret == 3) {
//Facebook & Twitter
var browserUrl = "";
var shareUrl = "";

if(progId.length > 5){ // Facebook
shareUrl = "www.facebook.com";
} else { 
shareUrl = "www.twitter.com";
}

if(ret == 2){ //Facebook
browserUrl = "http://www.facebook.com/sharer.php?u=" + /*encodeURIComponent(*/shareUrl/*)*/;
} else { //Twitter
browserUrl = "https://twitter.com/share?url=" + /*encodeURIComponent(*/shareUrl/*)*/;
}

launchBrowser(browserUrl);
} else {
//do nothing
}
} catch (e) {
alert(e);
}

Retired
Posts: 1,561
Registered: ‎04-12-2010
My Device: BlackBerry Z10
My Carrier: Bell

Re: Back button doesn't work in an invoked or launched app

Hello henrik,

 

I haven't been able to produce the issue at hand. I did note that bbui.js does implement its own control over the back button, however I implemented a sample here with two pages that you can navigate between, as well as a button that invokes the Messages application. The navigation between pages worked just fine and, upon launching the Messages application, I could return to my sample app by clicking the back button. No build-up of key presses.

 

One thing I did notice is that you are using the blackberry.ui.dialog.customAsk API. This is a blocking method (i.e. execution does not continue until a response is received.) However, this API has been deprecated:

https://bdsc.webapps.blackberry.com/html5/apis/blackberry.ui.dialog.html#.customAsk

 

In favour of this API:

https://bdsc.webapps.blackberry.com/html5/apis/blackberry.ui.dialog.html#.customAskAsync

 

Basically, you provide a callback function that is triggered once a choice is made. I would highly recommend attempting to modify your sample to use the asynchronous version as the peculiar behaviour being seen may simply be a symptom of leveraging an API that is no longer being developed.

 

Beyond that, I can not see anything in your code that would really raise any alarms.

 

Erik Oros

BlackBerry Development Advisor


Erik Oros | @WaterlooErik | eoros@blackberry.com | Developer Issue Tracker

If a reply has answered your question, please click Accept as Solution to help other visitors in the future.
New Developer
Posts: 13
Registered: ‎02-17-2012
My Device: 9860, 9900, playbook
My Carrier: Telenor (Sweden)

Re: Back button doesn't work in an invoked or launched app

Thanks for all the help.  will use the customAskAsync next time.