Latest Entries »

VideoPlayer for iOS 4.2

Trust me, all the videos on you tube will work for earlier versions of iOS, but

I needed it to work for me in iOS 4.2, and after a lot of mix and match of code, found the following to

work well.  Here is the code in the ViewController implementation :

-(IBAction)playMovie {

//Get the Movie

NSBundle *bundle = [NSBundle mainBundle];

NSString *moviePath = [bundle pathForResource:@"sample_iPod" ofType:@"m4v"];

NSURL *movieURL = [[NSURL fileURLWithPath:moviePath] retain];

theMovie = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];

//Place it in subview, else it won’t work

theMovie.view.frame = CGRectMake(0, 0, 480, 320);

[self.view addSubview:theMovie.view];

//Resize window – a bit more practical

UIWindow *moviePlayerWindow = nil;

moviePlayerWindow = [[UIApplication sharedApplication] keyWindow];

[moviePlayerWindow setTransform:CGAffineTransformMakeScale(0.9, 0.9)];

// Play the movie.

[theMovie play];

}
I have this setting for LandScape on a iPhone 4.

Well, everything worked for you in the simulator, now you got a device and you are going to put it to test.

Before we move too fast, a few things to understand:

  • As of date, one does not have to buy a device to download the iPhone sdk. You can always go to the link http://developer.apple.com/programs/register/ and register as a Apple developer for free. You will get an Apple ID and you can download the sdk.
  • And then create your project in Xcode (btw, Xcode is not preinstalled, if you bought a new machine, you can install it from the installation CD, and upgrade the version from the iOS Dev Center athttp://developer.apple.com/devcenter/ios/index.action) and set your target as the Simulator and learn iPhone programming to your hearts content.
  • However, for serious debugging and testing before releasing to customers, it is advisable to use the actual device, as features like the Accelerometer, Memory, Performance, Camera and GPS can be tested. I do not know whether there is a 3rd party software to do that for the iPhone (like there is atleast one for the Android). However, Simulators are just that, they cannot guarantee 100% compatibility. They are best used for checking resolutions over various iPhone versions (and multiple devices in case of Android).

Given that it is necessary to test with a Device and distribute your app to the App Store, and since Apple does not provide this for free. One has to join the iOS Developer program (http://developer.apple.com/programs/ios/ ) which is $99 for individuals.

Go to iOS Dev Center main page at http://developer.apple.com/devcenter/ios/index.action, and click on iOS Provisioning Portal link on the right hand column or go directly tohttp://developer.apple.com/ios/manage/overview/index.action

Follow the steps on the Right hand column.

Obtain your certificates (Both Developer and Distribution certificates)

  • Download and double click on them, you should be able to see them in your Keychain Access utility (Keychain Access utility is available in Applications->Utilities

Assign Devices

  • You can assign only 100/account, deassigning wont reduce the count, so be careful about assigning Device Ids in your provisioning profile for testing purposes)
  • You need to go to Xcode->Window->Organizer and click on the option that suggests that the USB connected device is the device you need for using for development on that particular computer

Create your App IDs

NOTE: App ID (the application identifier – your unique app) is not your Apple ID ( along with the password, is used to identify you by Apple.)

  • Ex: let us say your company is CoolApps. Enter ‘CoolApps App ID’ in the description (this is just a guide, you can enter whatever you want!)
  • Enter the reverse dns for your company – com.coolapps.* in the Bundle Identifier portion
  • App ID is a combination of BundleSeed and Bundle Identifier. BundleSeed is created by Apple and given to you, so you have no control over that.
  • The default App ID is a wildcard one .* (It is associated with your default created ‘Team Provisioning Profile in the later section.).

Create Provisioning Profiles

  • By default ‘Team provisioning Profile: * , i.e is already created with the Wildcard App ID and available to you, which is all that is needed for you to Develop, but you will get into problem when you try to Distribute you app, which has to have files in the com.coolapps.* format and not just a mix of com.sample1., com.sample2. and com.coolapps.*.
  • Create another development profile (Highly recommended) e.g CoolApps Development Profile – which is created with the App ID in the reverse dns format.
  • Create a Distribution profile e.g CoolApps Distribution Profile – which is created with the App ID in the reverse dns format.
  • At this Stage, In the Provisioning portal, all Provisioning profiles should be ‘active’ and all device status should be showing ‘installed’

Going for the Build to deploy your app on your Development Device

  • In Xcode , change from Simulator to Device (in the dropdown at the top of the Xcode window), so that your target for application deployment will be the Device.
  • The default ID which is a wild card ID is like a catch all iD, when associated in Code Signing (if you are using sample files to build, they will most obviously not have com.coolapps.appfile imports, in which case without the ‘Team Provisioning profile’, your build would fail. So you would want to set this in your
  • Xcode->Project ->Edit Project Settings->Build (tab)->Code Signing Identity (header) ->Any iOS (change from Any iOS Simulator)->(select ‘iPhone Developer’ as value and it will default to the wildcard development provisioning profile (Team Provisioning Profile: * )

and also (VERY IMPORTANT)

  • Xcode->Project ->Edit Active Target ->Build (tab)->Code Signing Identity (header) ->Any iOS (change from Any iOS Simulator)->(select ‘iPhone Developer’ as value and it will default to the wildcard development provisioning profile (Team Provisioning Profile: * )
  • You might want to change the reverse dns by editing info.plist in your project (if you are using sample projects to customize your project. (This is not needed for error free build – but an important consideration nevertheless!).

Testing with the Development profile that you created will help you when you move to distribute the App and build with the Distribution profile which also has AppID in the reverse dns format

I’m assuming that you had this project working with the iOS simulator – Click on Build and Run

VOILA! – You MUST not get any Code Sign error and your application MUST be deployed to the Device.

Many developers are having issues after installing the Android 2.3 SDK – aka Gingerbread, especially when you receive an error that android_sdk/tools adb.exe is not found. In this particular case, updating the Eclipse ADT Plugin solved the issue. Older ADT plugins were still referring to SDK/tools folder. I thought I’d share my experience of the step-by-step drill, for minimum pain/pain-free setup.

(I am using JDK 1.6, Eclipse Galileo SR2)

Please note that including adb.exe path in the environment PATH variable is only necessary for accessing adb through command line.

I followed the following steps – and have a working environment on both MAC and Windows:

  1. I have the path to tools as well as platform-tools in the Android sdk folder set as so:
    • Appended to PATH in .bashrc and referenced .bashrc from .bash_profile (MAC)
    • Appended to PATH environment system variable (Windows)
  2. Unzipped SDK to /Developer/SDKs (Mac) and in D: on windows (after having it in C: earlier an losing everything in a crash :)) – for windows one can use the executable provided by Google.
  3. Install the Android Repositories and Add-ons (for Google API)
    • Go to bash prompt (by clicking on Terminal in Utilities) and type android (this will open the AVD and SDK Manager (Mac)
    • Click on Setup.exe inside the SDK folder (Windows)
    • Select Available packages on left pane. -Open Third party add-ons and check on Google Inc for Google APIs. (I personally have unchecked everything obsolete, to add in the future IF needed)
    • Click on Install Selected.
  4. Create AVDs
    • Again bring up the AVD and SDK Manager as in the earlier step
    • Click on Virtual Devices on left pane.
    • Name: AVD_2.3 for level 9, 1024 MiB and click OK AVD_2.3_GA for level 9 Google API, 1024 MiB and click OK. And so on for the other levels
  5. Update Eclipse ADT Plugin
    • Go to Eclipse ->Help->Install New Software->Link of available software, and select on the Android Plugin choices and Click on Update..(this is extremely important, otherwise you will get the error of adb not found in the next step.
  6. Specify Android SDK Location in Eclipse
    • Select Eclipse Preferences->Android (MAC)
    • Select Windows->Preferences->Android (Windows)
    • Browse to the path to the SDK folder (not the tools or any other folder) and click OK. Now you MUST NOT get the adb error :) If you have done everything right, you should see all the AVDs. If you do not see the AVDs which you created in step 4, close the dialog and open it again, you MUST see all AVDs which you created.
  7. Getting Ready to Build
    • Go to your android projects. Right click on project in left pane and in properties select Android, and check on the AVD you want to run (i.e in the emulator).
    • Go to Java build path on left pane and click on the library tab if you don not already have the proper library seen select Add Library, and chose the specified project. This must work, If this does not work select Add External Jars and browse to SDK/platform//android.jar. Say OK.
  8. Build your Android Project (from Project Menu or right click – whichever the platform allows – should be successful!) (I personally clean the project before building, esp, when I am testing a SDK for the first time :)). It is quite possible that you have no source errors but there are 2 references in Android->Java build path->Library.  Remove the external jar reference and keep only the Library reference.
  9. Right click on your Android project->Run As->Android Application.

The Major cost cutting measures over the board are (Many points are not limited to IT industry):

1. Restructuring: Involves, merging teams and facilities which have similiar functionalities and trim. Hiring is frozen, or approval process for urgent requirements elevated to C Level exectives.

2. Budget squeeze: Less international travel, more work done through video conferencing. Newer hardware is not purchased, more stress is laid on increasing storage and memory instead of purchasing new servers etc. More stress on using free Open source softwares across the company.

3. Reduction in Internal projects: Pet internal projects are a no-no, more stress is on Customer projects.

4. Streamlining: Reduce projects where Matrix dependencies are there.

5. Working hours: Closer watch on time spent at work through. Work hour applications. More Network monitoring to check time spent on non-work related websites etc. Time lost is money lost.

6. Manager to Technical Staff ratio is reduced.

7. Quality processes are stressed: Rework means more wasted work, and increases costs.

8. Inventory control: Inventory is closely watched, and more stress is laid for JIT (Just -in- Time) resources.

9. Employee vs Contract: More contract labor is hired, as fixed costs are low during this recession period.

10. Smaller projects which generate revenue faster are favored. Similiarly suppored licences are favored as New licenses are difficult to come

Use Spreadsheet:

X Axis:
Effort (hrs), Resource (Manager/Lead/SSE/SE), Required (Keep/Postpone), Deliverable (date), Comments.

Y axis:
Planning: Communication, Documentation (Planning Doc, Func. Spec Doc)
Design Documentation: Architectural, HLD, LLD
Design Prototype: Major Module, Use Case
Development: Major Module, Use Case
Testing: Major Module, Use Case
Deployment: Module, Use Case

Each feature will have estimates based on your experience of a previous feature, if reqd take help from other leads who are experts in that module.

Each User Case may have a path across layers Client->Service->Business->Data Access->Database
Deployment may be in Application Servers
Hosting might have to be looked into,

You might need help from 3rd Party libraries, and licensing of software might be involved.
One has to consider all these factors and have them in the NOTES, so that the Client is aware of the contingencies.

And also, with more experience you will become more adept at arriving at estimate times that are pretty close to the actual end-end time.

Thick Client vs Web Rich client vs Mobile Client, all have variations in times esp at the Front end, and sometimes when client wants flexible design, we have to incorporate the necessary flexibility in the Services so that the client change should not affect the other layers of the application.

There are a few important things to consider when trying to extend existing enterprise apps to the Mobile device.

1. Latency issues – Networks are not same everywhere. Should be able to use multiple network options GPRS/EDGE/Wi-Fi. You will ultimately have to connect and communicate with an Enterprise Server.

2. Memory – Don’t expect your application which works on 4GB of RAM on a PC/Laptop will work without a hitch on your mobile. We could have other applications like Mail, and background services which are running and use up plenty of available device memory.

3. Storage – Saving a sound byte is different from Saving a video byte, if you decide to record and store some data on your device before transmitting it to the Server, decide whether you have the capability to do so for a hour long video.

4. Design with Disconnected in mind – keep Data entry possible even when not connected to the Server. Databases like SQLite can be used Mobile devices to reduce the pain. So that Data can be Sync’ed as soon as connectivity is available.

5. Screen Real Estate – Knowledge that having a browser for the PC/Laptop and expecting it to work the same on the Mobile device are two different things. Pinch In/Out and other zoom facilities can only ease the pain, but the basic design for Client View and Navigation have to be specific to a Mobile audience.

6. Availability of other 3rd party apps – Is your mobile device having the OS which is ready for Not only your applications, but also applications that are used by your application. e.g Support for Document, Spreadsheet etc.

7. VPN support: Working with your mobile app, with your Field service personnel for example might require enhanced security which a VPN can provide.

8. Leveraging technology – Technologies which give Mobile apps the edge, e.g use of Augmented reality within your application. Very useful when real-estate or car-dealers would like to show you a 360 degree streaming view of your remote object of desire, along with your customizations.”

These are not language specific.

1. Code should be READABLE. If not…please don’t code!
2. If you are using a DESIGN PATTERN, check with your lead, whether it is the right one in the given situation.
3. If you don’t COMMENT your code, you have not documented it.
4. If you did not make NULL CHECKS, your code will fail!.
5. If you use STATIC everywhere, you leave yourself open to memory issues.
6. If you do not handle EXCEPTIONS, you should not code, or review it.
7. If your code is not UNIT TEST able, you have not written it right.
8. Do not add Numbers directly as FLAGs or ENUMS, use readable constants instead.
9. EXTERNALIZE all User Visible Strings.  (Keeping it flexible for Multi-lang apps.)
10. Add Parameters that could change, in CONFIGURATION files.
11. Do not use Popup Message Boxes for Testing, use Console PRINT statements instead. You will forget to remove them!
12. Using LOGS in proper places, can enhance code, and avoid 11. in many cases. This is the only thing that will help you in remote communication from the customer end. Also helps in timing the functions and troubleshooting performance issues
13. Expose commonly used Utility Classes in UTILS package. Keep a note on its size, as not all Classes may need the whole package, it is a good practice.
14. Avoid practice of STAR importing (i.e importing whole Package e.g. java.lang.*)
15. When Synchronization is not needed, avoid using Synchronized Classes (e.g Do not use Vector when ArrayList would do the work).

I can see why Design patterns are thought of as difficult to understand.
Best Practices, are on the other hand are easier to follow and review.

Most Process oriented companies have ‘Golden Templates’ and ‘Coding Guidelines’ to make it easy for the programmers and other stakeholders.
Architectural vision – This is trickier than propagating the CEOs vision and the Product Roadmap. Architecture is something better explained in ‘High Level blocks’, when explaining to a Novice audience (a broad knowledge may help!).
To get to know it better, it requires one to look at the ‘Forest’ without losing sight of the ‘Trees’. The ‘Big Picture’ as we call it.

1. Why are Design Patterns difficult?

Programmers are people who work with Logic, and Logically they do not seem to get it because, “You are getting the desired Runtime Output you wanted, the User cannot see the code, What are you cribbing about?” So, most are not open to it, till they are given a maintenance project or Someone else’s code to work with.
I have tried to consciously do this with beginners before “Pair programming” became fashionable.
You learn both ‘Good’ and ‘Bad’ practices by observing others code, and hence hopefully, be a better programmer. To understand why something is better, one has to be introspective too.

Applying design patterns is all about ‘Unlearning’, and any unlearning takes a conscious effort on the part of the programmer. Does that mean we should start with Patterns, NO, that would be a great mistake. It is not about ‘Giving’ and ‘Accepting’, It is more about making the student ready to ‘Accept’, Something like a good Advertisement or a Jingle, it works on your subconscious, and makes you open to experiment.

2. Do Design Patterns need to be difficult?

Not at all! Why do most of us point out GoF book to those who want to learn Design patterns, why not a HeadFirst book? – I did not learn by my C++ from Bjarne Stroustrup, I did it from Stanley Lippman, and Scott Meyers.

I have favored the ‘Top Down’ approach to learning Design patterns.
Actually I found it very helpful to go through Michael Duall’ s ‘Non Software Examples for Design Patterns (pls Google it). If you search with “pdf” along with the above string, you get a good pdf of the content on the website.

Giving more real-life examples, makes the abstractions of patterns sensible. We tend to see application of patterns in code instinctively, that is when we know all the hard work has not been wasted :).

All good Code generators and Open Source frameworks use patterns.
With the advent of Open source, coding has generally improved :), we tend to do something better, if we know, there will be other eyes watching it.

We speak so much about ‘Scientific Temper’, I think it is high time, we spoke about ‘Pattern Temper’ :).

Trying out HootSuite for biz, currently kept my Facebook profile out of this. Facebook and Orkut tend to be bit more personal for my taste.

Hello world!

Welcome to WordPress.com. This is your first post. Edit or delete it and start blogging!

Follow

Get every new post delivered to your Inbox.