Activities are the basic components of any Android app. You may ask what exactly is an activity in android? By definition:
An activity represents a single screen with a user interface just like window or frame of Java.
By digging deeper into this definition, we find that it is what helps us draw the user interface. There can be multiple activities, but always only one "Main" or launching activity which is the one the user interacts with when the app is launched for the first time. Activities basically follow state transition patterns, which basically means it goes through a series of steps right from initialization until it is stopped. In very basic layman terms, you can consider an activity lifecycle to be metaphorically similar to a vendor.
As per a vendor's business lifecycle, say to start a business a vendor needs to create the objects of the trade, followed by actually starting to setup the objects of the trade ,then opening up his store for business, followed by ongoing transactions, followed by taking breaks in between when necessary, then returning back to business, followed by stopping for the day, then returning the following day and when the business doesn't work out selling out the store and shutting down for good.
Similarly, an activity is the vendor in this case. You need to first create the activity. This is done in the onCreate() method, where you initialize the essential components of your activity (say objects of trade). That is followed by onStart() method where these objects become visible (opening up the store where these objects are about to become visible to clients) , then you get into the flow where the activity has become visible, which is done through the onResume() method( in this case the objects that are being sold come under focus of the clients), followed by the activity running phase, where the activity is in the running state (our vendor is in business!) , followed by onPause where the activity loses focus (usually due to another activity taking over , in our case analogous to taking breaks) , followed by onStop where the activity is no longer visible( shutting down the store), but can always be restarted as and when required, in which case it goes back to onStart() method (aka opening the store), followed by onDestroy method where the activity gets destroyed( out of business!).
In this way, the entire lifetime of an activity revolves between the call to onCreate() and the onDestroy() states, whereas the visible lifetime starts between the onStart() and onStop() states.
Also, the foreground lifetime of an activity basically happens between the onResume() and onPause() states. The diagram below illustrates the activity lifecycle which we just discussed in brief detail:
The Beautiful world of Activities
8:40 PM | | 0 Comments
Welcome to the world of Android
A new beginning, a fresh start or a new challenge, whatever you would like to call it, A couple of years ago, precisely back in 2013 I decided to make the switch to Android. To learn more about this field, to explore it's features and everything that people brag about starting from the basic features which android developer's claim that Apple stole from Android.
I decided to write this blog after being dormant for years to share my knowledge about the basics, to be able to share what I learned in the simplest way possible as I have done in the past and hey of course teaching is the best form of learning. So without further delay, let's get started.
Now , you would ask me, what is Android? The definition says:
" Android is a mobile operating system developed by Google, based on the Linux kernel and designed primarily for touchscreen mobile devices such as smartphones and tablets."
But digging deeper into the technical side, as a developer, it's much more than the mere definition listed above. Let's cover the basic diagram as below:
1:17 PM | | 0 Comments
Geolocation with html5 and javascript
Every April, NYU holds a huge open-house event called NYU Day that draws 60,000+ visitors to the campus to view exhibits highlighting the research conducted at the university and participate in various events and activities. All of the event details are entered into a ColdFusion application, and one of those details is the GPS coordinates (latitude and longitude) of where each event is taking place so visitors to the website can see where the events are located on Google Maps.
Now that smartphones are becoming more prevalent, I wanted to see if it was possible to build a web application that would show the user where they were currently located and then show them on a map how to get from their current location to a particular event.
So I did some research and learned that HTML 5 comes with a Geolocation API. This API allows you to execute Javascript functions within the navigator.geolocation object built into the browser that retrieve the supposed latitude and longitude coordinates of where the browser is located (and, if available, the altitude, heading, and speed at which the browser is moving).
Using the code examples I found on the Gelocation API page on the W3C website and on Oliver Wehren's geolocation demo page, I was able to create my own test page for determining my location and marking it on Google Maps. I then tried using the page with my iPod Touch, and my friend's iPhone.
The default web browsers on all three devices implemented the Geolocation API ( the Dolphin Browser, did not). Each of the browsers displayed a confirmation dialog asking for permission to share my location information with the web page (as mandated by the standard), and once I permitted the information to be used, my test page was able to place a marker denoting my location on the map.
However, the location wasn't as accurate as I had hoped. Although the API was coded to accept location data from the on-board GPS system in a mobile device, neither the iPhone nor the Droid seem to provide GPS data to the browser. If I was connected to the campus wireless network, my location was determined via the network topography, and it could be off by as much as 150 feet or so. The accuracy was even worse if I was relying solely on 3G: in that scenario, but the iPhone and the Droid had me located on the side of a state road on the outskirts of campus, a good twenty minute walk from where I actually was. I have no idea what caused both devices to pick that particular spot, as there certainly wasn't a cell tower anywhere near that location.
So I came to the conclusion that while the Geolocation API could be used to determine what town, city, or general area a user was currently in, it wasn't accurate enough (at least with these browsers in these devices) to provide walking or driving directions within a small area, especially given the fact that many of the users for the service I had in mind would only have access to the Internet via a 3G connection.
But if someone knows of a way of increasing the location accuracy of the Geolocation API, a way that doesn't require the end-user to modify their mobile browser in order to make it work, I'd love to hear about it.
Keep Smiling,
Love and Respect,
Veswan
3:07 PM | | 0 Comments
The XCODE IDE
Seldom do people describe about the Xcode IDE.It is just left out in the corner, with the expectation that people will get used to its architecture, as they go along coding, but in my personal opinion, I believe that if you know the tips and tops of your IDE, you can code in any way you desire, with proper knowledge of error producing threads and the rest. You can even detect the compatibility and leaks and consistency of the code as desired.
Let's get started.
so this is what xcode logo looks like( if you've never seen one before)
There are multiple versions of xcode, the latest one being Xcode 4 released by apple on March 23,2011.
It is a complex programming platform for iphone and ipad development, where you can build and test your apps using the various possible simulator/emulator options available with the IDE.
As you tread along the Xcode IDE, you will come across a lot of new things which you are probably not familiar with. Let us go through them step by step :
As you can see in the figure, xcode 4 is also termed as single window IDE, where you can find different options in one place.
Xcode 4 presents an entirely new user interface and workflow for developers, along with new components for compiling, debugging and finding and correcting common errors. The result: better, faster code from more productive developers.
Rather than spawning new windows to search code, debug, build, and set parameters, everything can be done within a single window that echoes components of the design of iTunes, including a LCD-like status display.
The new window presents a dismissible Navigator control (akin to iTunes' Source List), with icon tabs that can present a variety of different types of development-related information within the same window column:
* a listing of projects and files
* a symbol listing of classes and methods
* a search feature that lists project-wide results
* an issues listing of build errors
* debugging information
* breakpoints
* a listing of build logs
The main area of the new Xcode windows is devoted to the document being viewed, whether code, a data model, or the project's graphical interface. This area can also be segmented to view multiple documents, presenting a comparison of their differences (such as for comparing two versions of the same code file). The content area also integrates support for viewing PDFs and other file types supported by the extendable Quick Look feature.
An integrated IB(interface builder) exists within this new xcode version.It's basic purpose is to add components to your project, including all simple functions like buttons and display of the UI. It will not only help developers code on the multiple window platform while looking at the existing code, but also help them achieve the goal of understanding the programming theme as they go along the project, which will in turn help in expediting the project at a much faster rate eventually.
This new comparison feature Will help people compare the codes in the project which will help them keep track of the flow of the programming parameters and the in general scenario as they tread along wiTh the project in the long run ,to understand where the error occurred and how it can be fixed.
besides these awesome features,another major feature delivered alongside Xcode 4 will be a new version of Instruments (originally code named Xray), Apple's graphical tool for code performance profiling based on Sun's DTrace technology.
The new Instruments adds new time profiler support for iOS development, and includes new features that help developers examine how their application code interacts with other apps and the system's kernel, in order to find where apps are spending their processing time and allocating their resources in a very complex computing environment.
This way xcode 4 IDE will make programming easy and make the whole process flow tracking, designing and coding experience fun, making project coding convenient for everyone involved in any given project at hand.
Thanks for reading,have a wonderful day !!!
Regards and smiles,
Vishwan Aranha :)
P.S: Instruments is also said to include support for identifying abandoned memory that has been referenced but not actually needed, enabling developers to reduce the memory footprint their apps demand. The tool will also add profiling analysis support for OpenGL ES, an important tool for iOS developers building high performance games and other apps that make use of sophisticated graphics.
8:43 AM | | 0 Comments
Mobile Functional Specifications
It's been quite a while since my last blog.So I decided to write another one just to save my blog writing talent.
The topic that I selected for this blog " Mobile Functional Specifications", sounds like a very corporate oriented, very boring topic, but did you know it forms the heart of any Mobile development project. There are thousands of books on iPhone development out there, out of which very few discuss this topic in detail. I like to question these books right away. Why? Why can't you guys specify about the functional aspects and requirements, but rather jump to the coding aspect which is only of relevance when a person just wants to learn coding with no BS involved.
Functional Specifications(FS) are no BS, for starters, these comprise of the requirements and the functioning(obvious) of the modules associated with any app. You can be a hardcore developer or designer, but without requirements properly laid out, you will keep coding and designing, till 2012(end of the world).
The best way to avoid lot of coding errors and looping in programming, is developing a strategy(requirement analysis) followed by code layout/technical flow explained, which helps us developers understand how to go about the project. It is like a torch that leads us through the dark path when we are roughly aware what the project goal is, but not about how to go about this goal.
Functional Specifications are usually dealt with by business analysts in any corporate environment, so us developers, disregard the fact that it is our responsibility to go through it as they do.
For instance, I was among the people who did the same. I used to disregard the specifications and scan through the well defined diagrams in FS and start developing asap, resulting in an extremely erroneous output, which took me ages to fix. In my recent project, we did not have any business analysts. At first I was apprehensive about it, I wondered how would I go about this project without one? how would I do the development like this? There were some FS's which were very roughly laid out and not that obvious.
I had given up hope, I thought time for another big messy project and the stresses that I would have to deal with because of module coding errors. But to my surprise, I read articales on gizmodo, consulted some nice Business analysts, got the templates and design from them and was able to lay out the structure and fill it in myself. A few drafts were formulated, but eventually I was able to nail it and guess what? I had awesome understanding and knowledge of the project requirements at hand and how to go about them. sometimes I think I would have preformed even better in the previous projects if no Business analysts were involved. might take time to do it without them, but atleast it would save months of coding errors(which is equivalent to spending time in hiring business analysts/ their involvement)
No I am not trying to take away the jobs from Business Analysts, but I am trying to mention that maybe in the Mobile environment we will be better off doing things by ourselves just to get perfect practical knowledge of the project requirements at hand( best experience in life comes from doing things yourself)
Most general Functional Design/Analytical or Technical Specifications consist of the following attributes:
Introduction
Module details(consisting of the following):
1. Requirements
2. Requirements Analysis
3. Functional Diagrams(Mock-up diagram/ state flow diagram etc.)
4. Feature Priority
5. Possible alterations/ additions for future( which basically help to lay out appropriate design during development to incorporate the possibility for addition of new features, thus helping to avoid rewriting code logic again and again.
6. Technical Overall flow( with possible diagrams)
Thus these self explanatory steps form the basic milestones in any Mobile development projects and help in improving the quality and style of any coding practice and most importantly it SAVES a lot of time and we all know time is money!
Lesson to learn: Never ignore FS, as it can really help you with ANY mobile project at hand.

Cheers!
Vishwan :)
10:40 AM | | 0 Comments
Dealing with Cross Browser & web-site Compatibility on iPad
Hello Everyone! Meet our friend, the iPad!
As surprising as it may sound, there are certain differences between iPhone and iPad ( obviously size being one), but I don't want to discuss them in detail on here, as that is not the topic under consideration.
But to understand the topic you have to know that an iPad has certain functionalities of iPhone and certain functionalities of computer, combine them together you get a padded iPhone like computer(resembles an iPhone but NOT at all it's big brother) , the iPad!
Now, you have to remember one thing, iPad does not support flash and some of the usual plug-in's you used happily on your computers!
First let us check ,how do you figure out your web-site is iPad compatible.
Step-1: The Simulation Testing!
If you're planning to buy an iPad and are keen on knowing if your website will work on iPad or what it looks like on iPad, here's something you can do!
a)Download Safari Browser(if you don't have one already, since safari is apple's pet, you can test most of their newer inventions on there, compatibility wise, as and when required)
b)Enter your website URL in safari(for example, let's check with one of my oldest website: www.glattmart.com)
c)Now on safari, on the top left corner, you'll see 'Safari',click on it, go to preferences, you'll see a number of tabs 'General,Appearance...Advanced',Click on Advanced and 'tick' or select "Press tab to highlight each item on webpage"option, followed by 'ticking' or selected another option that appears below it which says "Show develop menu in menu bar", Figure as follows:
d) Now select develop => User agent => Other, from the menu.
When prompted, copy the following string and paste it in the box.
Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10
Click OK, and the page will reload.
This is how the iPad will be able to 'see' your website.
Step-2: The Compatibility Test
As I mentioned before,some plug-in's will not work on iPad, say flash, certain 3D-2D Animations etc., the reason being iPad supports HTML5 & not certain web formats. Either you can remove those plug-in's or recode/embed them using HTML5 options.
Go to Safari’s "Safari" option on top left of the browser, from there go to "preferences" followed by Security Preferences tab, and in the “Web Content” options, you’ll see the checkboxes for each plugin. Uncheck “Enable plugins”.(In our case "www.glattmart.com" is in the URL for the test)
Before I unchecked the plug-in my website looked like this:
After doing that and reloading the page, it now looks like this:
The flash disappeared! This is because iPad would not support flash plug-in.So, you either replace that with something more compatible with iPad (Javascript/HTML5) or better not use it at all!
Once, all the non-compatible plugins are removed, and the site looks good, you might want to create a new URL specific for the ipad. Something like myexamplesite.com/ipad
And make sure that you add a canonical tag to the header pointing the iPad version to the original URL – so that you avoid duplicate content issues with the search engines.
Step-3: The re-direction!
It's time to redirect iPad users to specific URL using .htaccess
If you don't know what or where you can find .htaccess , I recommend you visit this link:
http://httpd.apache.org/docs/1.3/howto/htaccess.html
Now that you have an iPad compatible version of your website, just add a browser detection script for the iPad on your .htaccess file, as shown below.
This will detect all iPad users and forward them to the iPad version site, while the rest of the folks remain on the original URL.
RewriteCond %{HTTP_USER_AGENT} ^.*iPad.*$
RewriteRule ^(.*)$ http://yourdomain.com/ipad [R=301]
These are among the most common issues you face with iPad.
There are other script and gesture recognition(track pad click recognition and mouse recognition) issues with iPad, which might be a concern if you plan to code in those specific scripts( better start working on finding substitutes if you have an issue there).
That's one thing as far as website compatibility is concerned. Now let us look at a broader scenario.
If you're a coder/developer/designer like me and have these issues and want to test and implement the code in a way it works flawlessly then i recommend you use cross platform compatibility browser tools available online. You can check them out by clicking on this given link:
Click here
Hope the given information helps you with most of your browser compatibility issues.
If you have any questions or feel like sharing anything useful with regards to this topic, feel free to contribute via comments, feedback is always welcome!
Happy Browsing everyone!
Best,
Vishwan Aranha!
6:03 PM | | 0 Comments
Life Cycle in depth...
Dear Readers,
I hope my last blog was exciting enough for you to get till here. Remember, you can always ask me anything (in comments) or correct me or give some constructive feedback or even discuss some relevant topics, so we could be up-to-date on the latest things going on.I would love to hear some great feedback!
Let us look at the lifecycle right here:
Launch Application:
It is the first stage where the application is launched(obviously).How does it go through this stage is something we have to deal with in detail.
Application Initialization:
This is the stage where the application reaches the most important phase of its lifecycle where values and functions associated with its parameters come to life.
Load Main Nib/Xib:
Loading of the main nib file or xib file takes place in this stage, where the main view of the whole application is set for loading the interface for display.
Wait for event:
This is the in-line stage where the given functions wait for the event to occur or as some of you might say, where the target wait for the event to be triggered so as to take the associated action.
Handle Event:
This is the stage where the actual action associated with the event is handled and executed, or as you might say, this is the heart of the application.
Exit Application:
Finally when all the events are taken care of and the actions executed, and the user decides to close the app., all associated actions like release etc are executed and the application finally dies out/closes.
10:20 AM | Labels: apple iphone, ipad, ipad life cycle, iphone life cycle, life cycle of an iphone, lifecycle | 0 Comments







