EzDevInfo.com

titanium interview questions

Top titanium frequently asked interview questions

What is the correct way to chain async calls in javascript?

I'm trying to find the best way to create async calls when each call depends on the prior call to have completed. At the moment I'm chaining the methods by recursively calling a defined process function as illustrated below.

This is what I'm currently doing.

var syncProduct = (function() {
    var done, log;
    var IN_CAT = 1, IN_TITLES = 2, IN_BINS = 3;
    var state = IN_CAT;
    var processNext = function(data) {
        switch(state) {
            case IN_CAT:
                SVC.sendJsonRequest(url("/api/lineplan/categories"), processNext);
                state = IN_TITLES;
                break;
            case IN_TITLES:
                log((data ? data.length : "No") + " categories retrieved!");
                SVC.sendJsonRequest(url("/api/lineplan/titles"), processNext);
                state = IN_BINS;
                break;
            case IN_BINS:
                log((data ? data.length : "No") + " titles retrieved!");
                SVC.sendJsonRequest(url("/api/lineplan/bins"), processNext);
                state = IN_MAJOR;
                break;
            default:
                log((data ? data.length : "No") + " bins retrieved!");
                done();
                break;
        }
    }
    return {
        start: function(doneCB, logCB) {
            done = doneCB; log = logCB; state = IN_CAT;
            processNext();
        }
    }
})();

I would then call this as follows

var log = function(message) {
    // Impl removed.
}

syncProduct.start(function() {
    log("Product Sync Complete!");
}, log);

While this works perfectly fine for me I can't help but think there has to be a better (simpler) way. What happens later when my recursive calls get too deep?

NOTE: I am not using javascript in the browser but natively within the Titanium framework, this is akin to Javascript for Node.js.


Source: (StackOverflow)

How to deploy Titanium app on a real Android device?

I would like to know how to deploy from TitaniumStudio to a real Android device. I have a titanium app that works in the emulator. But I'm clueless how to get it running on the real device.

I know how to deploy my titanium app onto my iPhone using Xcode.

I have installed Eclipse too, and has managed to deploy a simple HelloWorld.app to real Android device with it.


Update: I have just learned that deploy can be accomplished using the commandline.

[ 12:49:59 ~ ] $ adb install /Users/johndoe/git/helloworld/build/android/bin/app.apk
772 KB/s (2035982 bytes in 2.573s)
        pkg: /data/local/tmp/app.apk
Success
[ 12:50:54 ~ ] $

Is there a way to deploy within TitaniumStudio?


Source: (StackOverflow)

Advertisements

Suggestions for entering mobile development -- pure iPhone SDK, Android SDK, Mono Touch or Titanium?

I am entering mobile development. I have been working primarily in .NET since 1.0 came out in beta. Before that, I was mostly a C++ and Delphi guy and still dabble in C++ from time to time. I do web apps quite a bit so I am reasonably proficient with Javascript, JQuery and CSS. I have also done a few Java applications. I started web programming with CGI and live mostly in the ASP.NET MVC world these days.

I am trying to decide on which platform/OS and tool to select. I am concerned with the size of the market available for my applications as well as the marketibility of the skills I will pick up.

The apps I have in mind would work on both phones and pads. Some aspects of what I have in mind will play better on the bigger screens that will be available on pads.

Here are the options I am considering:

  1. Apple iPhone/iPad using pure Apple SDK (Objective-C)
  2. Apple iPhone/iPad using Mono Touch (C#)
  3. Android using pure Android SDK (Java)
  4. Multiple platforms using something like Titanium to generate native apps from web technologies (HTML, CSS and Javascript)
  5. Multiple platforms using HTML5 web applications that run in the browser (HTML, CSS and Javascript).

Which option would you choose? Do you have a different suggestion? What are the pros and cons?


Source: (StackOverflow)

Label text is not updating in tableview children in titanium android.but work's in IOS

I have tried to update/change the lebel in android using titanium.but the value is not showing on the text .but am getting the updated value in the alert.But the ios is working perfectly.

 var itemcounttext = Ti.UI.createLabel({
 top: 5,
 color: "#000000",
 left:10,
 text:data[i].itemCount,
 width: Ti.UI.SIZE,
 height: Ti.UI.SIZE,
 });
var additem = Ti.UI.createImageView({
image: "/images/plus.jpg",
top: 5,
width: Ti.UI.SIZE,
left:10,
height: Ti.UI.SIZE,
});
adddeleteitemview.add(additem);
additem.addEventListener('click', function(e)
    {
        var item=e.source.getParent();
        squantity = e.source.squantity;
            squantity = Number(squantity) + 1;
            item.children[1].text = squantity;
            alert(item.children[1].getText());

Here am getting the alert with correct updated value.But the it's not showing in the label. Can you give me a idea to resolve this problem in android.

EDIT:

From VRK comment i have tried this also.But it's not working.but am getting the alert correctly.

item.children[1].setText(squantity);

EDIT:

I tried with jsplaine answer.But i can't get the solution. Here i have created the tableview .in this tableview row we are creating the view.in that view i have adidng the additem,itemcounttext values.if we are clicking the additem means need to change the itemcounttext value.This is a flow.

like below screenshot is children view of my app tableview:

productname

remove     itemcount   add
image      text        image

this three image,text,image values are added in one view.That's why am adding the code for getting the parent view while clicking add image:

var item=e.source.getParent();

here am getting the parent.also am wrote the below code for getting the label for this view:

item.children[1].text

If am clicking the add image, am getting the label value is incresed by 1 correctly .am verified with this code alert(item.children[1].getText());. but the updated value is not showing.This is my exact doubt.

EDIT:

This is my full source code.

 dataArray = [];       
 $.ViewCartItemslist_total_value.text = totalamount;
 for( var i=0; i<data.length; i++){ 

//creating the tableviewrow

 var row = Ti.UI.createTableViewRow({
 layout : 'horizontal',
 top:5,
 width: "100%",
 height: Ti.UI.SIZE,
 });
 row.add(Ti.UI.createImageView({
 image: data[i].image,
 top: 5,
 width: '50',
 height: Ti.UI.SIZE,
 }));
row.add(Ti.UI.createLabel({
text: data[i].name,
 top: 5,
 width: 180,
 font: { fontSize: '10dp' },
 color: '#040404',
 wordWrap: true,
 height: Ti.UI.SIZE,
 ellipsize: true
 }));

//creating the view inside of each every row of tableviewrow

 var adddeleteitemview = Ti.UI.createView({
 width: Ti.UI.SIZE,
 height: Ti.UI.SIZE,
 layout : 'horizontal',
 left:10,
 borderColor:"gray",
 borderRadius:"10"
 });
 var removeitem = Ti.UI.createImageView({
 image: "/images/minus.jpg",
 top: 5,
 left:10,
 width: "15%",
 height: Ti.UI.SIZE,
 });
 adddeleteitemview.add(removeitem);
 var itemcounttext = Ti.UI.createLabel({
 top: 5,
 color: "#000000",
 left:10,
 text:data[i].itemCount,
 textAlign:'center',
 width: "15%",
 height: Ti.UI.SIZE,
 });
 adddeleteitemview.add(itemcounttext);

 var additem = Ti.UI.createImageView({
 image: "/images/plus.jpg",
 top: 5,
 width: "15%",
 left:10,
 squantity : data[i].itemCount,
 spprice :data[i].itemPrice,
 height: Ti.UI.SIZE,
 });
 adddeleteitemview.add(additem);
 additem.addEventListener('click', function(e)
    {
        var item=e.source.getParent();
        spprice = e.source.spprice;
        if(item.children[1].getText() == e.source.squantity){
        squantity = e.source.squantity;
          totalqty = Number(totalqty) + Number(1);
            $.ViewCartItemslist_header_cart.text = totalqty;
            totalamount = Number(totalamount) + Number((spprice));
            squantity = Number(squantity) + 1;
            item.children[1].text = squantity;
           // item.itemcounttext.text = squantity;
          // item.itemcounttext.setText(squantity);
           // item.children[1].setText(squantity);
            alert(item.children[1]+" "+item.children[1].getText());
            $.ViewCartItemslist_total_value.text = totalamount;
            totalprice = Number(spprice) * squantity;
        }
           else {
                squantity = item.children[1].getText();
            totalqty = Number(totalqty) + Number(1);
            $.ViewCartItemslist_header_cart.text = totalqty;
            totalamount = Number(totalamount) + Number((spprice));
            squantity = Number(squantity) + 1;
            item.children[1].text = squantity;
            item.children[1].setText(squantity);
            alert(item.children[1].getText());
            $.ViewCartItemslist_total_value.text = totalamount;
            totalprice = Number(spprice) * squantity;
            }
           });
       row.add(adddeleteitemview); 

      dataArray.push(row);
    row.addEventListener('click', function(e) {
    });
    $.ViewCartItemstableView.setData(dataArray);
     }

Source: (StackOverflow)

RhoMobile Suite vs. Titanium vs. Xamarin vs. PhoneGap vs. Telerik Platform vs. Codename One

I, like many others, am looking to venture into mobile app development. I am familiar with HTML5, CSS3, JavaScript, PHP, Ruby, .NET but not Java or Objective-C. To be honest, I'm unlikely to become a mobile developer guru and the apps I will develop are unlikely to push the limits of Hybrid to such an extent that I ought to go native anyway. So the challenge for me is to gain enough knowledge to confidentally align myself to one of the mainstream Hybrid development platforms - knowing that I made the right decision according to my requirements.

I've been reading similar posts on SO and researching the currently popular Hybrid Mobile application development 'solutions' including:

Xamarin Titanium Rhomobile PhoneGap The Telerik Platform

I've come to the conclusion the decision on which to go with is not so simple. In fact, I'm no closer to making a decision than I was when I started. I'm therefore turning to the community to recommend which options based on my specific criteria (which I believe reflects most self-employed developers working on a small project-by-project basis rather than a larger corporate development team with the ability to fund licence costs etc.)

The apps I will build will need versions for Android and iPhone and should be able to access to the basic core phone functions including: Camera, Accelerometer, Geolocation, Alert, Local Storage, G-Sensor etc. but not much more.

So, this post is not a subjective 'Which one is best?', instead I'm looking for recommendations according to the following requirements:

  1. Free (preferrably) but at least affordable to the little man so: 1a. Affordable monthly subscription (if I have to) 1b. No hidden licence fees when it comes to distributing my applications - this is a biggy.

  2. Dev platform should install on Windows and Mac (so I can build for the platform myself) 2a. Alternatively, any integrated online build services should be affordable

  3. Environment should be straightforward to install and configure (is there such a solution? Nearly all I have tried seem to have some kind of issue whilst locating reference files, versions, launching emulators etc.)

As a .NET MVC developer, Xamarin seems the obvious choice but the starter cannot invoke 3rd party libraries - I imagine I would need this - and the barely affordable 'Indie' at $299 is per year per platform and I'm not certain it would offer all the functionality needed. The Enterprise version at $1899 per year per platform is way beyond budget.

Rhomobile Suite with its MVC Ruby approach seems a good fit for me but the documentation need attention (out of date) and there does seem to be massive ambuguity around the licensing of it. I can't find a definitive answer and they haven't responded to a straightforward request. I found this: "Use of RhoElements does require a license key, to make use of just the non-enterprise features (i.e. a Rhodes app) just remove app_type:rhoelements from your build.yml." - of course it is likely I would need RhoElements! Looking at the Application Licensing (on docs.rhomobile.com site) it seems you can get them from Motorola Solutions (or a heap of other resellers) but typically I cannot find a price. This concerns me - I can forsee me being hit with a $10,000 fee when I distribute to the app stores.

Titanium also has ambiguity over the licensing. Some are claiming they are been chased for $5000 licences by UK resellers others suggest that is simply wrong and there are no licence fees. Again, no idea...

In comparison, PhoneGap does appear to tick the boxes and I don't see concern over licensing but compared with the other solutions it comes across as needing more of a manual process with unpolished results - although that could be more to do with the apps I've seen in examples rather than the capability of the platform.

The Telerik Platform seems good on the face of it but I doubt the 'developer' offering at the current price of $39 a month (marketed as "ideal for tinkerers and hobbyists") is enough so I'd be looking at a commitment of $79 a month paid one year up-front - ouch! I'm also unsure if this cost covers all licensing of complete applications (I would hope so).

As one of my key criteria is ease of install, configuration and build, I am leaning towards Rhomobile or Telerik depending on the final costs to me as the developer for building and submitting these apps.

All things considered am I on the right track or still very uninformed?

Many thanks.


Source: (StackOverflow)

appcelerator vs phonegap vs native XCode speed-to-market

Titanium claims it can do the same app on average 70% faster than native XCode.

What's been everyone else's experience in terms of difference in speed of development (between native XCode and PhoneGap or titanium) ?

Let's say an app like Kik Messenger or Badoo ....

Typically, a good XCode developer can do it in 4-5 weeks, assuming graphics and backend are in place.

What would it take for an experienced Titanium (HTML5) person to achieve this? (roughly)


Source: (StackOverflow)

Titanium Appcelerator - should I use the alloy framework? [closed]

I'm developing an app using Titanium Appcelerator.

It's a simple flashcards app for iOS which allows users to scroll through a selection of foreign words, and view the equivalent english translation on 'the other side' of the card (flip transition!). Each card has an audio link and there are a few options for the user to choose also.

I would like to know if anyone reccommends the use of the alloy framework?
Does it speed up the development time?
Are there any use cases where alloy would not be appropriate?


Source: (StackOverflow)

PhoneGap vs. Titanium

PhoneGap and Titanium allow you build native iPhone Apps based on HTML and JavaScript.

Has anyone gained experience with both? What are the differences?


Source: (StackOverflow)

Choose between PhoneGap & Titanium

So, I have to develop a mobile application and I want to use Phonegap or Titanium but I need advice about those technologies...

Are they for free? What are their limitations?

I don't really understand them and I want to have more information before I start coding...

Thanks!


Source: (StackOverflow)

Contending with JS "used before defined" and Titanium Developer

I have a lengthy JavaScript file that passes JSLint except for "used before it was defined" errors.

I used normal function declarations, as in...

function whatever() {do something;}

as opposed to...

var whatever = function(){do something;};

and consistent with Steve Harrison's reply to an earlier post...

Assuming you declare all your functions with the function keyword, I think it becomes a programming-style question. Personally, I prefer to structure my functions in a way that seems logical and makes the code as readable as possible. For example, like you, I'd put an init function at the top, because it's where everything starts from.

... I like seeing the functions in an order that makes sense to me.

The script functions perfectly in the several browsers tested (e.g., FireFox, Safari, Mobile Safari, Fennec, IE, Chrome, Midori, etc.).

Here's the problem: I want to use the script inside of an iPhone app being built with Titanium but its compiler stops with "used before defined" errors.

How can I get around this?

This might be a stupid question but also... If functions need to be called in a particular order, how does one resolve the matter of a called function needing to call back to the function that originally called it? For instance...

function buildMenu(){
     Display a list of five menu items, each of which calls a function to build the associated screen.
}

function screen1() {
     Display the screen associated with menu item #1.
}

If the functions need to be declared in order, function screen1 would need to precede function buildMenu. But what if, under certain conditions, screen1 cannot be built and hence wants to redisplay the menu (i.e., calling a function that is technically not yet declared)?

Oh yeah... one more question: Are there websites or programs that automatically re-sequence the functions rather than requiring the programmer to do it manually?


Source: (StackOverflow)

Xcode duplicate symbol _main

I'm getting the following error in Xcode 3.2.1 on Snow Leopard 10.6.2 whenever I try to compile any iPhone application generated by Appcelerator's Titanium . However , the build error only appears when I select iPhone simulator on the architecture menu , and if I select iPhone device , I am able to run the app on my device .

Further , the iPhone simulator launches successfully and executes the program directly from the Titanium environment , which uses Xcode to build .

Why is this happening ?

ld: duplicate symbol _main in Resources/libTitanium.a(main.o) and /Users/prithviraj/Documents/project/Final/build/iphone/build/Final.build/Debug-iphonesimulator/Final.build/Objects-normal/i386/main.o collect2: ld returned 1 exit status Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 failed with exit code 1


Source: (StackOverflow)

How to append a row to a TableViewSection in Titanium?

I'm developing an iPhone application in Titanium, and need to append a row to a particular TableViewSection. I can't do this on page load, as it's done dynamically by the user throughout the lifecycle of the application. The documentation says that the TableViewSection has an add method which takes two arguments, but I can't make it work. Here's my existing code:

for(var i = 0; i <= product_count; i++){
    productsTableViewSection.add(
        Ti.UI.createTableViewRow({
            title:'Testing...'
        })
     );
}

That is just passing one argument in, and that causes Titanium to die with an uncaught exception:

2010-04-26 16:57:18.056 MyApplication[72765:207] *** Terminating app due to uncaught 
exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of rows in 
section 2. The number of rows contained in an existing section after the update (2) must be 
equal to the number of rows contained in that section before the update (1), plus or minus the 
number of rows inserted or deleted from that section (0 inserted, 0 deleted).'
2010-04-26 16:57:18.056 MyApplication[72765:207] Stack: (

The exception looks like it did add the row, but it's not allowed to for some reason. Since the documentation says that TableViewSection takes in "view" and "row", I tried the following:

for(var i = 0; i <= product_count; i++){
    productsTableViewSection.add(
        Ti.UI.createView({}),
        Ti.UI.createTableViewRow({
            title:'Testing...'
        })
     );
}

The above code doesn't throw the exception, but it gives a [WARN]:

[WARN] Invalid type passed to function. expected: TiUIViewProxy, 
was: TiUITableViewRowProxy in  -[TiUITableViewSectionProxy add:] (TiUITableViewSectionProxy.m:62)

TableViewSections don't seem to support any methods like appendRow, or insertRow, so I don't know where else to go with this. I've looked through the KitchenSink app, but there are no examples that I could find of adding a row to a TableViewSection. Any help is appreciated.


Source: (StackOverflow)

Desktop application development with Javascript and HTML

I am looking for Titanium Appcelerator alternatives for Desktop application development with HTML and JavaScript. I want to convert a web app to a desktop application. Hence, there will be a lot of server interaction. Appcelerator was a good choice, but it looks like the company is no longer interested in the Desktop SDK. Also, ajax request from Appcelerator does not retain cookies.

I read that Adobe Air can be used for desktop app development, but I don't want to use flash.

How good is XULRunner? Will it allow features like Growl notificaiton and creating tray icons?

Will I be able to develop applications using mostly Javascript and HTML in Qt?


Source: (StackOverflow)

Is Appcelerator Titanium now banned on the iPhone?

This question has been answered quite clearly for MonoTouch here: http://stackoverflow.com/questions/2604033/is-monotouch-now-banned-on-the-iphone

But what about Appcelerator Titanium?

The new TOS from Apple and their iPhone 4 OS:

3.3.1 — Applications may only use Documented APIs in the manner prescribed by Apple and must not use or call any private APIs. Applications must be originally written in Objective-C, C, C++, or JavaScript as executed by the iPhone OS WebKit engine, and only code written in C, C++, and Objective-C may compile and directly link against the Documented APIs (e.g., Applications that link to Documented APIs through an intermediary translation or compatibility layer or tool are prohibited).

Titanium uses JavaScript but is not executed be the iPhone OS WebKit engine directly. In their Developer blog, Jeff Haynie says Titanium is on the clear, but I don't know if they are in denial.

It’s our belief that we are fully in compliance with iPhone OS 4.0 ToS as we interpret them.

I haven't found any official word by Apple, only opinions. And I'm quite confussed. I'm not writing another line of code for my App until... you know.


Source: (StackOverflow)

getting error msg install failed missing shared library

i have made one application which uses google maps APi,i am using titanium 1.2.2 and mobile sdk 1.5.1 for android,wenever i am trying to run the app on emulator,console shows an error

[INSTALL_FAILED_MISSING_SHARED_LIBRARY]

what does this error means and how to fix it??


Source: (StackOverflow)