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
The code to make partially transparent object with LUA scripting is described below. Let us say we have a rectangle object and we want to make it semi transparent. Code Block : –Define the cordinates of rectangle object local left, top, width, height = 100, 100, 50, 50 –Define the rectangle local rectangleObj = display.newRect(left,top,width,height) […]
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’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
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 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
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 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
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
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
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 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
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
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 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
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 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
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
Sometime we need to make rounded corner rectangle object. For our iPhone/Android app we can do this easily using LUA scripting. The code to do so is described below. Code Block : –Define the cordinates of rectangle object local left, top, width, height = 100, 100, 150, 150 –Define the radius of the corner for […]