Posted on November 24th, 2015 by Raju Mahato
Sometimes we need to store/access data from external storage devices in our mobile apps. But before storing or accessing data we can check whether the storage device (SD card) is present or not. Using titanium, easily we can verify that. //Ti.Filesystem.isExternalStoragePresent(); //Returns boolean value //Check external storage if(Ti.Filesystem.isExternalStoragePresent()){ //Do the read/write operation on file […]
Posted on November 24th, 2015 by Raju Mahato
Twitter integration on iPhone/Android application using Titanium. Most of the cases we need to integrate our application with Facebook, Twitter etc. The process, how can we integrate twitter with our cross platform iPhone/Android application using titanium is described below. First of all we need to include one JS library file named birdhouse. We can get […]
Posted on November 24th, 2015 by Raju Mahato
To store data in application level properties using Titanium, we need to define the property and than assign data to them. //Store the string type data “Test Name” with a key name “userName” Titanium.App.Properties.setString(‘userName’, ‘Test Name’); //Store boolean Titanium.App.Properties.setBool(‘isAnnual’, true); //Stores integer Titanium.App.Properties.setInt(‘totalAmount’, 20986); //Stores double Titanium.App.Properties.setDouble(‘rateOfInterest’, 5.36); //Stores list data Titanium.App.Properties.setList(‘userList’, [‘user1’, ‘ user2’, […]
Posted on November 23rd, 2015 by Raju Mahato
Suppose we have a iPhone/Android app and one of its window there is a textbox near to the bottom. So onclick/focus of this text box a kepad will appear which will covered the textbox. So if we type anything at that moment, the character will appear on the textbox but we cannot see them as […]
Posted on November 23rd, 2015 by Raju Mahato
Using Titanium, code to capture images with device camera is described below. Let say we have a window with a button to activate the device camera. //Define the current window var myWin = Titanium.UI.currentWindow; //Define the button to activate camera var cameraBtn = Ti.UI.createButton({ title : ‘Click to activate Camera’, top : 10 //Set the […]
Posted on November 23rd, 2015 by Raju Mahato
Let say we have a file “log.txt” on device application directory and we want to move it to another directory. //Assuming the file exist in the directory //gets our file var logFile = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory,’ log.txt’); //Another directory var logFolderDir = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory,’logFolder’); //check the directory existance if(logFolderDir.exists()){ //Moves the log file to log folder logFile.move(‘ logFolder/ […]
Posted on November 23rd, 2015 by Raju Mahato
Webview is used to show the html content. Using titanium we can easily access native functionality from the html content. The code to do so is described below. Lets say we have a span in our html content and onclick of that we will add a native label to the window. //Defines the current window […]
Posted on November 23rd, 2015 by Raju Mahato
Code to describe transaction with SQLite in titanium is mentioned below. Let say we have a simple employe table and we will insert employee data in bulk. //Define an array holds employee data var empData = []; //Data added to the array empData.push({id:’001′, name:’emp1′}); empData.push({id:’002′, name:’emp2′}); . . . empData.push({id:’00n’, name:’empn’}); //************* […]
Posted on November 23rd, 2015 by Raju Mahato
We are generally using WebView to display our html content to our apps. For iPhone app, if we add any html content to a webView it works fine as we expected, but for android the UI get distorted little bit. Horizontal and vertical scrollbar appears to that view. To fix that all those issue use […]
Posted on November 23rd, 2015 by Raju Mahato
Let’s say you have a app.js file where you have mentioned all your controls. Then you need to make a file with extension “jss”. So here is the sample code – Code for app.js: var win = Ti.UI.currentWindow({className : ‘winStyle’}); var mainView = Ti.UI.createView({id : ‘viewStyle’}); win.add(mainView); Code for app.jss: //For ID # viewStyle { backgroundColor:#336699; […]
Posted on November 23rd, 2015 by Raju Mahato
In various scenario, we need to upload or download files to our application. And while upload/download of files we can track the progerss of uploading/downloading. The following code block can accomplish the job easily in application made by titanium. Lets say we have files need to download and we will track the download progression with […]
Posted on November 23rd, 2015 by Raju Mahato
Code to download files using our cross platform iPhone/Android app in Titanium is described below. Code Block : //Url of the file that need to be downloaded var downloadingFileUrl = “Url of the file that need to be downloaded” //File path where downloaded file will be saved var fileSavingPath = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory,”file_Path”); //Define the http client […]
Posted on November 23rd, 2015 by Soutam Dhara
Titanium Supports differents type of Module for iPhone and Android. This is Titanium-Calender Module for iPhone. You can download the source code from https://github.com/stelford/Titanium-Calendar Details instruction of using this module in titanium app also describe in this link.
Posted on November 23rd, 2015 by Lopamudra Joshi
In Titanium in case of android, if we define “touchstart” and “click” events for a button, the click event will not work untill we defined the “touchend” event for that button. But for iPhone the click event does not depends on “touchend” event. So the code to accomplish the job in both OS the without […]
Posted on November 23rd, 2015 by Raju Mahato
Process to play video from a local folder with windows desktop application usingTitanium are follows : In titanium we have a html page where we can specify the UI of the application and we can also have javascript file where we can write our scripts. So lets in our html page we have defined a […]
Posted on November 23rd, 2015 by Raju Mahato
The way to show alert dialog box using titanium is described below. //Define alert dialog var alertDialog = Titanium.UI.createAlertDialog({ title : ‘Alert Message’ }); //Set the alert message alertDialog.setMessage(‘Custom alert message’); //Displaying the alert message alertDialog.show();
Posted on November 23rd, 2015 by Raju Mahato
Suppose we need to post data to remote server using titanium. Let say we have to send user name and password. The following code describes the process. //Define the parameters that need to send var params = { ‘userName’ : “testUser”, ‘password’ : “testPassword” }; //Creates httpClient var xhr = Titanium.Network.createHTTPClient(); xhr.open(‘POST’, “URL of the […]
Posted on November 23rd, 2015 by Sourabha Sahoo
You can make your Android application to be displayed only in portrait mode using Titanium by making following changes. 1.Create directory platform/android in your project directory. 2.Copy AndroidManifest.xml file from build/android directory and paste it inside platform/android that you have already created. 3.Edit the AndroidManifest.xml file inside platform/android directory by adding android:screenOrientation=”portrait” in all activity […]
Posted on November 23rd, 2015 by Lopamudra Joshi
Let say we have a window and we need to give background gradient. /Define a window var win = Ti.UI.createWindow(); //Apply the background gradient win.backgroundGradient = { type : ‘linear’, colors : [‘color1′,’color2’], startPoint : { x : 0, y : 39 } };Let say we have a window and we need to give […]
Posted on November 23rd, 2015 by Raju Mahato
Lets say we have a JS file named “utility.js” to have all our custom functions. Suppose we have defined one function here like //Function to show custom message exports.showMessage = function(msg){ Ti.API.info(“Custom message : ” + msg); }; Now we want this function in a different js module like in “user.js“ Instead of including […]
Posted on November 23rd, 2015 by Raju Mahato
Check your mail is sent or not with emaildialog with your iPhone/Android apps using Titanium. Using emailDialog from your iPhone/Android apps with titanium we can send mail. But there is a way we can check, the mail is sent or not easily. Code Block : //Creates the email dialog box var myEmailDialog = Ti.UI.createEmailDialog(); […]
Posted on November 23rd, 2015 by Lopamudra Joshi
Google Maps is the most common platform implementation and the one both Android and the iPhone platforms utilize. Here we will implement a mapView by providing lattitude and longitude of a particular region. Let us create a view //create our mapview var mapview = Titanium.Map.createView({ top: 110, height: 350, mapType: Titanium.Map.STANDARD_TYPE, region: {latitude: 26.00, longitude:94.00, […]
Posted on November 23rd, 2015 by Raju Mahato
Some time we need to have option dialog to show the options to user allowing to chose one. Using titanium, code for option box is described below. Suppose we have a button, and on click of that button we need to show the option dialog. //Define the option box var optionBox = Titanium.UI.createOptionDialog({ title : […]
Posted on November 23rd, 2015 by Raju Mahato
Sometime we need to attach file with our mail to send someone. Using titanium, in our iPhone/Android apps we can do it with following way. Code Block: //Define a email dialog var emailDialogToSend = Ti.UI.createEmailDialog(); //Add the mmessage body emailDialogToSend.messageBody = “Message body content”; //Get the file var myFile = Ti.Filesystem.getFile(“FileName”); //We can also take […]
Posted on November 23rd, 2015 by Raju Mahato
Access data from local SQLite database in Titanium cross platform applications. Let say we have a simple database named “myTestDb” where I have a table called employee which holds employee data (Id and name). //Define a variable var db = {}; //Query to get employee details db.empDetailsQuery = “SELECT EMP_ID, EMP_NAME FROM EMPLOYEE”; //Open data […]
Posted on November 23rd, 2015 by Raju Mahato
Associate phone menu button with our application. We can do this with the “activity” property of window. The code is described below. //Creates window with activity property var win = Ti.UI.createWindow({ backgroundColor: ‘#fff’, //defines the background color of the window navBarHidden: true //Hides the nav bar activity: {//For Android only onCreateOptionsMenu: function(e) { var menu […]
Posted on November 23rd, 2015 by Raju Mahato
Rendering remote json data to a TableView in Titanium. Suppose I have a Json feed that hold all employee names. I need to create a table with rows having their names. Code to perform this job is described below. //Array variable to hold data var employeeData = []; //Define a tableview var employeeTable = Ti.UI.createTableView(); […]
Posted on November 23rd, 2015 by Raju Mahato
Suppose we have few files into the resource folder of a desktop application made by Titanium. To get those files with that application I have used the following piece of codes. //Get the resource folder path var resourceFolderPath = Titanium.Filesystem.getResourcesDirectory(); //return an Array of items inside this directory var fileList = resourceFolderPath .getDirectoryListing(); Now this “fileList” […]
Posted on November 23rd, 2015 by Raju Mahato
Facebook integration on cross-platform mobile app using Titanium. The following code is tested with iPhone,iPod and Android. Let say we have a view. Onclick of that view a window will appear to make post on Facebook. Ti.Facebook.appid = ‘Your_Application_Id’; // We will get this ID, when we will regiter this app on facebook Ti.Facebook.permissions = […]
Posted on November 23rd, 2015 by Raju Mahato
While moving from one window to another window in a mobile native application we can use different transition animation style. There are few posible transition styles described below for iPhone app using Appcelerator Titanium. //Different transition style var transitionStyle = { curlDown : Ti.UI.iPhone.AnimationStyle.CURL_DOWN, //Curl downwards during a transition animation curlUp : Ti.UI.iPhone.AnimationStyle.CURL_UP, //Curl upwards […]
Posted on November 23rd, 2015 by Raju Mahato
Sometime we need to extract images from device gallery in our application. Process to accomplish this using titanium for iPhone/Android devices are described below. Let say we have a window with a button to open gallery from device. //Define the current window var myWin = Titanium.UI.currentWindow; //Define the button to activate camera var openGalleryBtn = […]
Posted on November 23rd, 2015 by Sourabha Sahoo
You might need to find the screen width and height of Andriod/iOS devices to make your application compatible in different sizes of screen. So by using the following lines of code you can fetch the screen height and width of Android/iOS devices with Titanium. //fetch the height of the screen var screenHeight = Ti.Platform.displayCaps.platformHeight; //fetch […]
Posted on November 23rd, 2015 by Raju Mahato
Using Appcelerator Titanium we can do some cool animation effects. One of them is scaling. Let say we have image and onClick of that image I want to scale down the image. So here is the code to do that described below. Code Block : //Define the current window var myWin = Ti.UI.currentWindow; //Define the […]
Posted on November 23rd, 2015 by Raju Mahato
Repeat animation for fix number of time in your iPhone app using Titanium. We can repeat the animation effects with a fix number. Let say we have an image and I want to scale up/down continuously for 5 times. So here is the code to do that described below. Code Block : //Define the current […]
Posted on November 23rd, 2015 by Raju Mahato
Email message as HTML content in iPhone/Android apps using Titanium. There is a way where we can send messages as like html content from our iPhone/Android apps built in Titanium. The process to do so is described below. Code Block : //Define a email dialog var emailDialogToSendHtml = Ti.UI.createEmailDialog(); //Allow to show the message body […]
Posted on November 23rd, 2015 by Raju Mahato
Continious image scale in and out in iPhone using animation with Titanium. Continiously we can do image scale in and out animation using titanium. Let say we have image and I want to scale up/down continiously. So here is the code to do that described below. Code Block : //Define the current window var myWin […]
Posted on November 23rd, 2015 by Raju Mahato
Rotate image continiously in iPhone apps using Titanium. Rotate an image continiously. Let say we have an image and I want to rotate it continiously. So here is the code to do that described below. Code Block : //Define the current window var myWin = Ti.UI.currentWindow; //Define the Image var myImg = Ti.UI.createImageView({ width : […]
Posted on November 23rd, 2015 by Raju Mahato
Rotate an image for a specific angle in iPhone app using Titanium. We can rotate any image for a specific angle using titanium. Let say we have an image and I need to rotate it to 180. So here is the code to do that described below. Code Block : //Define the current window var […]
Posted on November 23rd, 2015 by Raju Mahato
Let say we have few video clips and we need to play them continiously with in our iPhone app. The code to play videos continiously are described below. Code Block : //Current window var myWin = Ti.UI.currentWindow; //Lets we have three clips named “clip1.mp4, clip2.mp4, clip3.mp4” inside a directory and we will play them continiously. […]
Posted on November 23rd, 2015 by Raju Mahato
Sometime we need to perform some job while opening a new window in our application. For the time lets say we will show an alert message informing which page we are moving. The code to do so is described below. Code Block : //Define the current window var employeeWin= Ti.UI.currentWindow; //Define a button var changeWinBtn […]
Posted on November 23rd, 2015 by Lopamudra Joshi
While window load text box in Android automatically gets focussed as a result the Android Soft Key Board Pops Up. To Remove this automatic Popping Up of key Board use the following Code. Note : Text Field is mentioned as Pg.searchBar where the Window name is Pg.win Pg.win = Titanium.UI.currentWindow; //searchBar creation Pg.titleText = Ti.UI.createTextField({ […]
Posted on November 23rd, 2015 by Raju Mahato
We can open a new window using URL properties of Ti.UI.createWindow element. But considering the performance, It will be slow. So we can open a new window in some other steps, which is quite faster than previous one are described below. Suppose we are in login Employee page and we will move to Employee details […]
Posted on November 23rd, 2015 by Raju Mahato
Some applications require active internet connection to run on our smart devices. So here is a simple way to check connectivity and its status using Titanium described below with an example. Code Block : //Define the current window var currentWin = Ti.UI.currentWindow; //Define a Button var getDetailsBtn = Ti.UI.createButton({ width : 100 //width of the […]
Posted on November 23rd, 2015 by Raju Mahato
At times there are requirements in an application where we need to play sound with some action in background. There is a way to do that in cross platform application using Titanium, the following block of code accomplishes it. //Define current window Var currentWin = Ti.UI.currentWindow; //Define a button var playSoundBtn = Ti.UI.createButton({ width : 100, […]
Posted on November 23rd, 2015 by Raju Mahato
Generally in Appcelerator Titanium we are using numbers in pixel to set the position (left/right/top/bottom) of a control in a window for an app that will run on different platform (IOS/Android). But there is a problem with this process. Android has devices with different resolution and in that case the control position gets altered due […]
Posted on November 23rd, 2015 by Raju Mahato
If we need to show data in row format, usually we use TableView in Titanium to build crossplatform application where we some time give alternate row color to each row. Here is code snippet to describing the scenario. Code Block : //Define the current window var currentWin = Ti.UI.currentWindow; //Array variable having row data var […]
Posted on November 23rd, 2015 by Lopamudra Joshi
Navigation group is used to navigate between two or more pages in iPhone in an animated / sliding way. The API provides with a back button which can be used to go back to the previous view. For a navigation group to exist there should be at least a root level window that would act […]
Posted on November 23rd, 2015 by Lopamudra Joshi `
This tip demonstrates how to add custom controls to a navigation group and change navigation group color/image. For changing color barColor property of a window is set to a color and for changing/ assigning an image to navigation group the barImage property is used. In the following snippet a root window created, in which one navigation […]
Posted on November 23rd, 2015 by Raju Mahato
Its very common for a developer to deal with table and its rows and to know about the number of rows present in the table. I have often faced problems related to this. Finally I got the solution which is described below. CODE BLOCK : //Define current window var currentWin = Ti.UI.currentWindow; //Define table view var dataTable = […]
Posted on November 23rd, 2015 by Raju Mahato
Here is a sample code to show location from address using titanium. Lets say we have text box on which we will type address and on click of a button it will show the location. CODE BLOCK : //Define the current window var currentWin = Ti.UI.currentWindow; //Define the textbox var txtAddress = Titanium.UI.createTextField({ left : 10, […]
Posted on November 23rd, 2015 by Raju Mahato
Here is a simple app describing AR (Augmented Reality). This app will simply display the view shown by the device camera and when user tap on the screen, the respected coordinates will be shown on an alert message. CODE BLOCK : //Define the current window var currentWin = Ti.UI.currentWindow; //Define overlay view which will have […]
Posted on November 23rd, 2015 by Raju Mahato
Application built using Titanium is generally large in size. So sometime it is advisible to install an app to the SD card added with the device. Titanium has ability to instruct the app installer to install te app to the SD card. Here is a way to do that. In order to that we need […]
Posted on November 23rd, 2015 by Raju Mahato
Here is a code snippet which explains how to remove annotations from mapview using Titanium. //Define the current window var currentWin = Ti.UI.currentWindow; //Define the resource directory var resDir = Ti.Filesystem.getResourcesDirectory() //Define a map var myMapView = Titanium.Map.createView({ top : 0, height : ( Ti.Platform.displayCaps.platformHeight / 4 ) * 3, //Define the height of the […]
Posted on November 23rd, 2015 by Raju Mahato
Here is a trick to use slider as progressbar described below. CODE BLOCK : //Define current window var currentWin = Ti.UI.currentWindow; //Define a button to strat the progress var stratBtn = Ti.UI.createButton({ width : 200, height : 50, title : ‘Strat Progress’, top : 300 }); //Button added to window currentWin.add(stratBtn); //Define a slider var […]
Posted on November 23rd, 2015 by Raju Mahato
On Android application we can use the Android menu button to show menu items to our application. Here is a code block describing the implentation. //Define current window var currentWin = Ti.UI.currentWindow; //Define Android current activity var androidCurrentActivity = Ti.Android.currentActivity; //Creating a menu androidCurrentActivity.onCreateOptionsMenu = function(event){ //Define menu var appMenu = event.menu; //Add home item […]
Posted on November 23rd, 2015 by Raju Mahato
Most of the times, we show item list in a tableview and it is also a common scenario for a developer to need to edit/delete/update a row on click of that row. Here is a trick describing how to display a delete button when we swipe that row. . //Define current window var currentWin = Ti.UI.currentWindow; //Define rows for a tableview […]
Posted on November 23rd, 2015 by Raju Mahato
While working with file downloading I came across a situation where I didn’t know the file type that I am going to download but I have to take some action depending on the downloaded file type. So here is the quick tip to know the file type before saving it to a directory after downloading. […]
Posted on November 23rd, 2015 by Raju Mahato
Some times we need to make attractive menu in our application. Carousel is one of the popular type. Here is a technique to make menu similar to carousel. Let assume the images representing the menu items are stored in images folder. CODE BLOCK : //Define the current window var currentWin = Ti.UI.currentWindow; //define the resources directory […]
Posted on November 23rd, 2015 by Raju Mahato
Application build using Titanium is generally large in size. So sometime it is advisible to install an app to the SD card added with the device. Titanium has ability to instruc the app installer to install te app to the SD card. So here is a way to do that. In order to that we […]
Posted on November 23rd, 2015 by Raju Mahato
Introduction : Its very common in web application, where when we takes our cursor over a link or image, generally we can see a tooltip describing about the control or tells about the control. So can we do something like that on our mobile app….? Description : Generally in web application, when we […]
Posted on November 23rd, 2015 by Raju Mahato
Introduction : Slider is a very common UI control used to select some value from a given range. And also we can use it to display a value with in a given range of values. So it is very common to those scenario. Description : Generally slider is displayed in horizontal layout, where […]
Posted on November 23rd, 2015 by Raju Mahato
Introduction : Using Titanium label API with js we can easily add a label to a screen. But today we will see how could we can add a label in an application following Alloy. Alloy provides MVC architecture to make an application where we will have model view and controller. Generally view will contain the […]
Posted on November 23rd, 2015 by Raju Mahato
Introduction : Alloy supports MVC pattern architecture where we can have view, model and controllers by which we can separate UI block and program logic. So here we will see how can we add clock event to an UI element. Description : In order to add click event to an UI element, lets add an […]
Posted on November 23rd, 2015 by Raju Mahato
Introduction : Generally table view is used to display data in different rows and its very common to have rows under sections like all the name of states will be displayed under state sections, all the name cities listed under city section. Description : Lets have a window with a table. And we will add […]
Posted on November 23rd, 2015 by Raju Mahato
Introduction : Tableview is a very common UI element used to display data in table row format. It is used to display information as organised section and row format. Description : Lets have a window where we will define a table and will add few rows to it. CODE BLOCK : index.xml <Alloy> <Window backgroundColor=’red’> […]
Posted on November 23rd, 2015 by Raju Mahato
Introduction : Section in tableview used to categorised the rows to different category. Here I am going to describe the way to append new section at the end of a table. To do this Titanium provides methods appendSection which is associated with tableview API. Description : Here is how to append section lets create a scenario […]
Posted on November 23rd, 2015 by Raju Mahato
Introduction : There might be a condition where we need to add custom rows at the end of all rows in a table view. So here Titanium provides method associated with table view API which helps us to do the same job. Description : To describe the situation lets make a view with a tableview […]
Posted on November 23rd, 2015 by Raju Mahato
Introduction : Usually we use scrollview to display large body of content which is scrollable. But when a user reaches to top or bottom end of that content, it shows bounce effect to that instance. Application built with Titanium can have the feature to block this bounce effect at the top and bottom ends. Description […]
Posted on November 23rd, 2015 by Raju Mahato
The process to send mail using Titanium is described below. //Define the email dialog var mail = Ti.UI.createEmailDialog(); //Assign the mail Subject mail.subject = ‘Mention the subject here’; //Assign the recipient address mail.toRecipients = ‘recipient address’; //Assign the message mail.messageBody = ‘Message in details’; //Which open the mail dialog to your window mail.open();
Posted on November 23rd, 2015 by Raju Mahato
Suppose we have a iPhone/Android app and one of its window there is a textbox near to the bottom. So onclick/focus of this text box a kepad will appear which will covered the textbox. So if we type anything at that moment, the character will appear on the textbox but we cannot see them as […]
Posted on November 23rd, 2015 by Raju Mahato
Suppose we have a iPhone/Android app and one of its window there is a textbox near to the bottom. So onclick/focus of this text box a kepad will appear which will covered the textbox. So if we type anything at that moment, the character will appear on the textbox but we cannot see them as […]
Posted on November 23rd, 2015 by Raju Mahato
The process to send mail using Titanium is described below. //Define the email dialog var mail = Ti.UI.createEmailDialog(); //Assign the mail Subject mail.subject = ‘Mention the subject here’; //Assign the recipient address mail.toRecipients = ‘recipient address’; //Assign the message mail.messageBody = ‘Message in details’; //Which open the mail dialog to your window mail.open();