Thursday, June 25, 2009

iPhone SDK dismiss the keyboard


Set the delegate on the text field that will bring up the keyboard. Add the following selector to the object that you set to be the delegate.

The controller's interface code
#import
@interface MyViewController : UIViewController {
IBOutlet UITextField *textField;
}
@property (nonatomic, retain) UITextField *textField;
@end
And the controller's implementation code
#import "MyViewController.h" 
@implementation MyViewController 
@synthesize textField;
-(BOOL)textFieldShouldReturn:(UITextField *)theTextField {
if (theTextField == textField) {
[textField resignFirstResponder];
}
return YES;
}
@end

Thursday, June 11, 2009

Converting a J2ME MIDlet to a BlackBerry COD

Converting a J2ME MIDlet to a .COD involves the following steps:

  1. Download and install the RIM Java Development Environment
  2. Download and install Java SDK
  3. Copy the jad & jar files in question to the /bin/ directory of your BlackBerry JDE installation
  4. From the command line (make sure you are in the bin directory of your RIM JDE installation) type:
rapc import=“$your_JDE_dir\lib\net_rim_api.jar" codename=$your_app -midlet jad=$your_app.jad $your_app.jar
Where,
$your_JDE_dir  - is the directory of your RIM JDE installation,
$your_app          - is the name of the MIDlet you're trying to convert $your_app.jad        - is the name of the MIDlet descriptor and
$your_app.jar     - is the name of the MIDlet jar file
  1. The following files are generated:
$your_app.debug
$your_app.cod
  1. $your_app.cod is used to load the application onto the BlackBerry 
 To load the application onto the BlackBerry Simulator:
  • Launch the BlackBerry Device Simulator by selecting Start => Research In Motion => BlackBerry JDE => Device Simulator.
  • Once the simulator is loaded, install the .cod file by selecting File => Load Java Program and load the $YOUR_APP.cod from $JDE/bin/
  • On the BlackBerry Simulator desktop find your application and launch it. 

Android Application Lifecycle

In Android, the applications are run as a separate Linux process. So the application lifecycle is closely related to the process lifecycle. The application process lifecycle is handled by the system depending on the current system memory state.
In case of low memory, the Android system kills some less important process. The process importance is decided depending on the state of the process components.
The process types depending on the importance are as follows (from most important to least important):
1. Foreground process: A foreground process is the application process with which the user is currently interacting. The process is considered to be foreground if its Activity is at the top of the Activity stack (its onResume() has been called) or BroadcastReceiver is currently running (onReceive() method is currently getting executed) or its Service is executing callback functions like onCreate(), onStart() or onDestroy() methods.
2. Visible Process: A visible process is the process which has an Activity visible to the user (its onPause() method has been called).
3. Service Process: Service process contains a Service for which startService method is called and the service is running.
4. Background Process: The background process does not have any visible activities to the user. (Activity onStop() method has been called).
5. Empty Process: Empty process is the one that does not have any active application components. These processes are kept on for caching purpose.
It is important that application developers understand lifecycle of the application process. Not using these correctly can result in the system killing the application’s process while it is doing important work.