Friday, May 18, 2012

Remote Debugging Phonegap application

For remote debugging your phonegap application use

Enabling Crossbrowser calls in Chrome


If you want your HTML file from the local file system, and that file will be able to make requests to other sites to access data or other resources in chrome browser,then run below command in terminal window.
 open -a /Applications/Google\ Chrome.app --args --allow-file-access-from-files --disable-web-security


Note : Before running above command close the chrome.

Thursday, April 26, 2012

Custom font in IPhone Application

Sometimes we have apply our own custom fonts in application.
Normally we add the fontfile name with extension to resources and a entry in plist.
In code we will use the font some thing like this

[lblTest setFont: [UIFont fontWithName: @"fontfilenamewithoutextension" size:30]];

But this doesn't works if font name is different from font file name.
To get the font name use below code.

   NSArray *familyNames = [UIFont familyNames];
    for( NSString *familyName in familyNames ){
        printf( "Family: %s \n", [familyName UTF8String] );
        NSArray *fontNames = [UIFont fontNamesForFamilyName:familyName];
        for( NSString *fontName in fontNames ){
            printf( "\tFont: %s \n", [fontName UTF8String] );
        }
    }

Pick the font name from the list which is printed in the log and then just replace that 
[lblTest setFont: [UIFont fontWithName@"fontname" size:30]];


Now your custom font works :).

Thursday, April 19, 2012

Disabling native iOS vertical window movement in phonegapp application

When we are developing phonegap application page moves up and down when we scroll in the webview eventhough page has little data.
- (void)webViewDidFinishLoad:(UIWebView *)theWebView 
    { 
              for(id subview in theWebView.subviews) { 
              if([[subview class]isSubclassOfClass:[UIScrollView class]]) 
              ((UIScrollView *)subview).bounces = NO; 

    } 
Just add above extra code in appdelegates.m file webviewdidfinish load function.


This will fix the issue.

Friday, March 2, 2012

Installing Apk on Android Emulator Window and Mac

Below are the Steps to install Apk on Windows Android Emulator.

Open command prompt
Go to Android Sdk folder.C:\android-sdk-windows\tools
In command prompt type adb install apkname.apk

If you don' find adb command then
Download the adb.zip file which contains adb.exe, AdbWinApi.dll and InstallAgent(batch file)
unzip and copy these files to tools directory.

Below are the Steps to install Apk on Mac os Android Emulator.

Open Terminal
go to android-sdk-mac\platform-tools
type ./adb install myApp.apk

If you get any error while installing on Mac just restart the adb.Below are the commands
./adb kill-server
./adb start-server

Note : copy apk to tools and platform-tools directories on windows and mac respectively.