How to open url in default browser using titanium in Blackberry - titanium

I am currently working on a project in titanium .I wish to open url in default browser of BB10
simulator instead of webview used in the app on click event .I am using the following code
var win =Ti.UI.createWindow({
title:'Test'
});
var webview=Ti.UI.createWebView({
url:"http://demo.php.otssolutions.com/videoapp-uat/home"
});
win.add(webview);
webview.addEventListener('click',function(e){
var url=e.url;
Ti.API.info(url);
Titanium.Platform.openURL("http://demo.php.otssolutions.com/videoapp-uat/home");
});
win.open();
Thanks in advance for any help

Related

Embedding Wistia video in a Mobile App developed using Titanium

We are developing a Mobile App using the Titanium framework, we need to embed some videos in one of the screens. Appcelerator API documentation that I am following is located here. My code looks as follows, currently it shows a blank screen :
var welcomeWin = Ti.UI.createWindow({
title:'Welcome Video',
backgroundColor:'#fff'
});
var videoplayer = Titanium.Media.createVideoPlayer({
top:2,
autoplay:true,
height:300,
width:300,
url:'https://fast.wistia.net/embed/iframe/thewistiaurl',
mediaControlStyle:Titanium.Media.VIDEO_CONTROL_DEFAULT,
scalingMode:Titanium.Media.VIDEO_SCALING_ASPECT_FIT
});
welcomeWin.add(videoplayer);

I want to open a PDF file within the application in titanium studio

I have URL of PDF file and want to open within the application so that i can navigate back to application. I don't want to go to browser. Can anyone help?
Check this out:
iOS:
http://docs.appcelerator.com/titanium/3.0/#!/api/Titanium.UI.iOS.DocumentViewer
Android
http://developer.appcelerator.com/question/72361/open-pdf-file-on-android
Or you could try and show it in a webview:
var pdfViewer = Ti.UI.createWebView({
url: "url.pdf",
width:1000,
height:1000
});

window.open addEventListener does not work on "Mobile Browser Simulator"

I'm using IBM Worklight 6.2
I'm using window.open to load some external pages for OAuth and I configure event listeners for the opened window.
var authWindow = window.open(authUrl, '_blank', 'location=yes');
authWindow.addEventListener('loaderror', function(e) {
console.log(">> load error. event: " + JSON.stringify(e));
});
also for "load" and "loadstart" events.
This works in Android and iOS but when I preview the app in the "Mobile Browser Simulator" the eventListeners are not executed.
I have also tested creating a "desktopbrowser" application.
Any idea?
Loaderror, loadstart, and loadstop are specific to Cordova and not supported in the Mobile Browser Simulator. It would be best to test these on emulator or device. Please see: http://cordova.apache.org/docs/en/3.0.0/cordova_inappbrowser_inappbrowser.md.html#addEventListener

open url in default OS browser

Is there a way to open URL in default OS browser?
I have MenuItem and want to open certain URL whenever user clicks this item:
var item = new gui.MenuItem({
label: 'Shortcut',
click: function(){
//here i want OS to open some URL
}
});
You can proceed like that:
gui.Shell.openExternal("http://website.com")
See the documentation here: https://github.com/rogerwang/node-webkit/wiki/Shell
See also How to open a browser window from a node-webkit app? for more informations.

IBM Worklight 6.0 - Cordova camera simulation in the Mobile Browser Simulator doesn't work

My camera code was working fine in WL 5.0.6 and the mobile browser simulator would correctly display the image. Now I moved to WL 6.0 andI get the following error when using the preview in the Mobile Browser Simulator and using the Cordova camera simulation to get a fake picture.
I am using Chrome for the preview.
Not allowed to load local resource: file:///C:/Users/Administrator/cordova/internal/sim/camera/camera1_m.jpg wljq.js:2374
The code is similar to this
navigator.camera.getPicture(onSuccess, onFail, { quality: 50,
destinationType: Camera.DestinationType.FILE_URI });
Note that if I use the DATA_URL, it seems OK with the mobile browser simulator. Just the FILE_URI doesn't seem to be working with the mobile browser simulator.
The Worklight 6.0 Mobile Browser Simulator supports Cordova 2.6 APIs. For navigator.camera.getPicture the following destination types can be used in WL 6.0:
Camera.DestinationType = {
DATA_URL : 0, // Return image as base64 encoded string
FILE_URI : 1, // Return image file URI
NATIVE_URI : 2 // Return image native URI (eg. assets-library:// on iOS or content:// on Android)
};
Example:
navigator.camera.getPicture(
function(data) {
document.getElementById('camera_status').innerHTML = "Success: picture located at " + data;
var img = document.getElementById('camera_image');
img.style.display = "none";
},
function(e) {
console.log("Error getting picture: " + e);
document.getElementById('camera_status').innerHTML = "Error getting picture.";
},
{ quality: 50, destinationType: navigator.camera.DestinationType.FILE_URI, sourceType: navigator.camera.PictureSourceType.SAVEDPHOTOALBUM, encodingType: fileType});
Try clearing your browser cache and then be sure to accept the applet permission dialogue on Mobile Browser Simulator startup. Also make sure that your file permissions will allow transfer from the C:/Users//cordova/internal/sim/camera/ folder as that is where the applet stores the camera sim image content.
Cordova 2.6 Camera API reference:
http://docs.phonegap.com/en/2.6.0/cordova_camera_camera.md.html
Funny, that there is already a troubleshooting document for your problem.
http://www-01.ibm.com/support/docview.wss?uid=swg21614861
It looks like DATA_URL didnt work in WLv5, while (if you are right) FILE_URI is not working since WLv6.