Tuesday, April 2, 2013

Best Practices for Mobile App Development on Android

Designing and building apps that look great and perform well on as many devices ranging from smart phones to tablets is crucial to ensure an optimal user experience.
At the recent DevFest Silicon Valley event held at Google on March 15th, I had presented a talk on Best Practices for Mobile App Development on Android.  The talk focuses on the Golden Rules & Best Practices of Performance including how to keep your apps responsive, how to effectively implement Background Services, tips for improving the performance and scalability of long-running applications, and briefly on Best Practices for User Experience and concluding with Benefits of Intents and Intent Filters.  For further details, please refer to the slides attached below.


If you enjoyed this article, you may want to follow me (@tasneemsayeed) on Twitter. I always announce significant new blog posts and interesting mobile topics via a tweet. You can also subscribe to this blog.  Feel free to post any comments that you may have below.
View more documents from tasneemsayeed.

Friday, March 8, 2013

Implementing Singletons for the iOS platform

The Singleton design pattern is one of the most frequently used design pattern when developing for the iOS platform. It is a very powerful way to share data across different parts of an iOS application without having to explicitly pass the data around manually.

Overview

Singleton classes play an important role in iOS as they exhibit an extremely useful design pattern.  Within the iOS SDK, the UIApplication class has a method called sharedApplication which when called from anywhere will return the UIApplication instance that is associated with the currently running application.

How to implement the Singleton Class

You can implement the Singleton class in Objective-C as follows:

 MyManager.h


@interface MySingletonManager : NSObject {
    NSString *someProperty;
}


@property (nonatomic, retain) NSString *someProperty;

+ (id)sharedManager;

@end

MyManager.m

#import "MySingletonManager.h"

@implementation MySingletonManager

@synthesize someProperty;

#pragma mark Singleton Methods

+(id) sharedManager {
    static MySingletonManager *sharedMySingletonManager = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        sharedMySingletonManager = [[self alloc] init];

    });
    return sharedMySingletonManager;
}
                  
- (id)init {
    if (self = [super init]) {
        someProperty = @"Default Property";
    }
    return self;
}

- (void)dealloc {
    // should never be called, but included here for clarity
}

@end

The above code fragment defines a static variable called sharedMySingletonManager which is then initialized once and only once in sharedManager.  The way that we ensure that it is only created once is by using the dispatch_once method from the Grand Central Dispatch (GCD).  This is thread safe and handled entirely by the OS so you do not need to worry about it at all.

If you rather not use GCD, then you can the following code fragment for sharedManager:

Non-GCD Based 

+ (id)sharedManager {
    @synchronized(self) {
        if (sharedMySingletonManager == nil)
            sharedMySingletonManager = [[self alloc] init];
    }
    return sharedMySingletonManager;
} 
 
Then, you can reference the Singleton from anywhere by calling the function below:

Referencing the Singleton

MySingletonManager *sharedManager = [MySingletonManager sharedManager];
Happy Singleton'ing!   If you find this post useful, then mention me in the comments.

View more documents from tasneemsayeed.

Monday, November 7, 2011

Driving Mobile Application Downloads

With iTunes now carrying 225,000 apps in its "curated" collection and Android up to 100,000, it is no wonder that app discovery is a major issue for application developers.  

Undoubtedly, one of the key decisions in launching a successful mobile application is determining how to drive application downloads.

Based on experience launching applications working in several mobile startups, I believe that there are at least six key mobile strategies to consider for driving adoption:

  1. Why is mobile media support needed? 
    • Mobile media support is needed since we need to reach consumers who may already have a mindset or may already be used to certain types of applications (i.e. facebook, twitter, etc). There may also be a need to educate users on issues such as privacy, security,  and so on.
  2. What should be the average marketing spend?
    • As a result of analyzing download trends and media spend across various advertisers, several marketing experts have determined that the minimum mobile media spend is $200,000 over two days to truly make an impact and accelerate measurable downloads.
  3. When should you begin mobile media support? 
    • The day of week apparently matters.  To leverage typical download activity, it is suggested to launch your application and begin supporting it toward the end of the week - on a Thursday or Friday. This is allow you to build on the momentum of the weekend downloads.
  4. How robust should the mobile application be?
    • It is critical to make your application robust because "first impression" matters. If an application frequently crashes or if critical functionality does not work properly, then it is likely that your application may not be subsequently used.  While multiple features such as video, pictures, gaming and maps make for a bigger experience, if consumers cannot download the application and subsequent updates in certain WiFi zones, then it will most likely inhibit downloads.
  5. Which form of advertising is more important: creative or contextual?
    • Based on mobile campaigns with those of digital display, marketing experts have concluded that in mobile media efforts, the banner creative has more of an impact on performance.  However, in online campaigns, contextual is typically more important.
  6. Which mobile devices need to be supported?
    • If you want to maximize coverage, then it is recommended that your application must be cross platform (i.e. must support iOS devices such as iPhone 3, 3GS, 4 and Android devices such as Droid X and/or HTC Evo).  However,  keep in mind that the uber-smartphone market represents less than 20 percent of smartphone penetration.  Therefore, by including all phones that can access the Web, you will not only build scale, but you may also experience higher conversion rates from some of the less sophisticated devices.
Driving application downloads is not the only factor for launching a successful mobile application, but it is certainly an important one.


If you found this article useful, please retweet and/or leave me a comment.

Friday, May 6, 2011

Just Released: FREE Sudokroid (Sudoku Game Puzzle) in Android Market

More than 10 billion apps have been downloaded since the launch of the Apple (NSDQ: AAPL) App Store—the majority of them via iPhones.  As of March 2011, 37 percent of mobile consumers who owned a smartphone had a device with an Android OS. Apple’s iOS, claimed by 27 percent of consumers, is now outpacing Blackberry, which has 22 percent of the market.


It only seemed appropriate that one of the first mobile apps I decided to release was an Android app, Sudokroid, to the Android Market. Sudokroid is a logic-based number placement puzzle, which initially starts with a partially completed 9x9 grid. The game provides the player with the options to start a "New Game", "Continue" an existing game, an "About Game" option to get further details for playing the game, and finally "Exit Game" to exit from the game.  




When the player selects a "New Game" , it will let the player select the difficulty level from a choice of 3 levels: "easy", "medium" and "hard". A new game grid is displayed, partially filled, while splendid soothing music is playing in the background!  If "Continue" is selected, then the game continues from the previous game state.



The goal of Sudokroid is to fill the grid so that each row, each column and each of the 3x3 boxes contains the digits 1 to 9 exactly once.  Hints are provided to help in the selection, and if a selection results in "no move", then the player can go back to the previous tiles and revisit some of the prior moves.

You can download the game for FREE from the Android Market from http://bit.ly/mO8qfE.  Be sure to rate it and tweet or leave me a comment !  Stay tuned for more apps in the pipeline!

Friday, November 12, 2010

iPhone Game Design Challenges

As Ernest Adam writes in "The Fundamentals of Game Design":
"Good games and game worlds possess harmony, which is the feeling that all parts of the game belong to a single, coherent whole. This quality was first identified by game designer Brian Moriarty. "

An excerpt from his lecture, "Listen: The Potential of Shared Hallucinations, (Moriarty, 1997) Moriarty explained the concept of harmony as follows:

Harmony isn't something you can fake. You don't need anyone to tell you if it's there or not. Nobody can sell it to you, it's not an intellectual exercise. It's sensual, intuitive experience. It's something you feel. How do you achieve that feeling that everything works together? Where do you get this harmony stuff?"

Not surprisingly, there are several challenges for designing games on the iPhone :

  1. The screen size is small (320 by 480 pixels). This small space leaves very little room for top header displays or menus during game play.
  2. Multitouch Interface
    • The multitouch interface on the iPhone has opened new and exciting user interface design opportunities. When the iPhone was introduced, it was completely revolutionary with its touchscreen interface that supports and can track multiple touches simultaneously.  This user interface breakthrough, and intuitive and innovative interface enhances the creativity in touchscreen gaming. It has already resulted in a total paradigm shift in the way designers now approach an iPhone game.
    • The ability of the iPhone interface to detect swipes and pinches gives us new ways of differentiating and responding to user input.
    • Instead of using buttons to zoom in and out of a game level, you can allow the user to zoom in and out using a pinch motion
    • Users can also take a look around a particular level just by swiping their finger across the screen to control the direction that the camera will pan
  3. Limited screen size has resulted in inspiring game designers to select novel control schemes. For example, you can use the built-in accelerometer to tilt or steer characters or other game objects instead of putting controls on the screen
  4. The accelerometer can also be used for detecting shakes or movements. This can be used in games to trigger an action or to reveal a hidden surprise
  5. The iOS Location Service (Core Location Framework) is a major feature that is typically overlooked by many game developers. The Assisted GPS (A-GPS) in the iPhone 3G can be used in many creative ways.  You can use it to control a user's motion during game play or to identify other users who are playing the game nearby. Also, once other game players nearby are identified, they could be sent invites to meet at a specific location for other social interaction (i.e. chatting, meeting in a photo gallery, playing other games, etc).

Saturday, October 30, 2010

iPhone: Tips for Extending Your Battery Life

After using an iPhone for a few days, you may discover that while these devices are very innovative, intuitive and fun than perhaps most other smart phones, they do not excel in battery life. Any dedicated serious iPhone user will surely need to recharge his or her iPhone almost on a daily basis.

There are ways to conserve your iPhone battery life, but many of them involve turning off services and features, which make it a choice between all of the cool things that the iPhone can do and making sure that it can retain sufficient juice to do them.

Here are some tips to help you extend your battery life:

  1. Dim the screen. Touchscreen drains the battery, so the brighter the default setting of the screen, the more it drains the battery, so reducing the brightness will conserve more of your battery. You can find it in Settings -> Brightness
  2. Cycle the battery. All Lithium-based batteries slowly loose their charging capacity over time. Let it completely discharge and then fully recharging it again.  To maintain optimal performance, you should cycle your iPhone or iTouch's battery every one or two months.
  3. Turn data push off. The iPhone 3G can be set to automatically push email and other data down to it whenever new data becomes available. Every time you access the networks, it costs you battery life, so turning off push will help to extend your battery life. When push is turned off, you will need to check your email periodically (see #4 below).
  4. Fetch email less often.  The more your iPhone needs to access the network, the more it consumes the battery. So, set your iPhone to check for new email less often (i.e. every hour or so). Or, ideally, set it to "Manual Check". You can find it in Settings -> Mail, Contacts, Calendar ->Fetch New Data.
  5. Turn Bluetooth off except when you are using it. Bluetooth wireless network is useful for users with wireless headsets or earpieces. But, transmitting data wirelessly requires juice, and leaving it on all the time can drain the battery even more. Turning off Bluetooth except when you are using it will help you conserve battery life. You can find it in Settings -> General.
  6. Turn off 3G if you are using the iPhone 3G and not downloading web content. The iPhone 3G operates on two cellular networks, EDGE and the faster 3G. Not surprisingly, using 3G requires more battery to get the faster speeds and the higher quality calls. It may be tough to go slower, but if you need more battery life, then turn off 3G and just use EDGE. You can find it in Settings -> General -> Network.
  7. WiFi is another high-speed network that the iPhone supports, which is even faster than 3G, though it is only available where there is a hotspot, not everywhere like 3G. The drawback is that if it is always enabled, it can quickly drain your battery life. Unless you are using WiFi right now, keep it disabled. Find it in Settings -> WiFi.
  8. Turn off Location Services unless you are using it right now. The built-in GPS is one of the coolest features of the iPhone 3G, which allows the phone to know where you are and gives you exact driving directions and gives that information to applications that can help you find nearby restaurants, etc. But, like any other service that requires network access, it needs battery life. If you are not using location services, then turn it off and save some battery power. You can find it in Settings -> General.
  9. Set your iPhone to 'auto-lock' sooner.  You can set your iPhone to automatically go to sleep sooner (aka Auto-Lock) after a certain amount of time. The sooner it sleeps, the less power is used to display the screen or other services. You may try setting it to 1 or 2 minutes. You can find it in Settings -> General -> Auto-Lock.  In the case of an iPad, you can put it into sleep mode when not in use by manually pressing sleep/wake button.
  10. Minimize your tasks (i.e. avoid background music) or running applications that require the phone to run for a long period of time or use up a lot of resources such as playing videos, games, browsing the web, etc. can use up a lot of battery power. If you want to conserve battery power, then limit the use of battery-intensive apps.

Tuesday, May 11, 2010

Is Mobile Advertising the next big thing?

There has been a lot of buzz among online advertising companies about mobile ads being delivered to smartphones.  Google's Chief Executive, Eric Schmidt has mentioned about Google becoming a "mobile first" company. Furthermore, Google's move with its acquisition of Admob, and Apple's recent announcement of its iAd Mobile Advertising platform demonstrates that mobile advertising continues to gain increased attention.

However, there are issues with advertising on mobile phones - the screens are too small even on today's smart phones. This makes it difficult to deliver a compelling advertising user experience to consumers. Also, when users click on the the traditional banner ads, it redirects them to a new browser window. So the user experience on the mobile phone is compromised.

Although spending on mobile advertising is growing, it is still a tiny portion of online advertising.  Up until now, mobile advertising has consisted mainly of small banner ads tucked into the corner of a mobile web page or text-message ads that often resembled spam.  According to market research firm, eMarketer, mobile advertising accounted for $416 million in spending in 2009, compared with $22.4 billion in overall online advertising.

The new Apple's iAd platform is looking to change the face and quality of advertising.  Apple's CEO believes there is a flaw of both standard online advertising and TV advertising - the combination of interaction and emotion. The key is that ads will keep users within an app, rather than redirecting users to a browser window.

When you click on an iAd advertisement, it will take up the screen using HTML5. Once it is open, you can explore the ad.  Apple demonstrated an advertisement for Toy Story 3, where it showed that you could not only get information about the movie, but you could also watch trailers, play games and do much more all within the same application from where you launched the ad.

Many technologists and analysts are putting a lot of bets on the standard HTML5 technology for enabling the creation of richer content experiences.  Furthermore, according to WSJ, several analyts are projecting a positive outlook for Apple's iAd platform as they believe that it will provide a significant source of revenue for Apple. Piper Jaffray believes that in-application advertising could reach roughly $700m by 2013, with about 70% going to ads within the iPhone platform.  But, can it really become a multi-billion dollar business ?