Tag Archives: class

Fast and Efficient way to transfer images between Activites in Android

By | July 14, 2017

We often need to transfer images between activities. Well there are many methods to transfer images. You can make the image into a Base64 String and pass it as String argument extra in a bundle between activities You can save it to a disc and read it in the other activity. Well, these methods will… Read More »

How to load a spinner with values from SQlite Database in android?

By | November 18, 2012

Here is a simple example showing how to load a database values in a spinner in android. OK we will start. This is the layout for the spinner row. spinner_row.xml This is the layout for the interface. activity_main.xml Now this is the MainActivity.java file that uses the spinner and the database. Join the Forum discussion… Read More »

How to make a http call repeatedly from a service in android?

By | July 14, 2012

We may have applications in which we may have to make repeated calls to a webservice. At that time services may be useful. This is such an example in which we will be creating a Service in android to create a repeated call to a webservice in a time delay of some seconds or milliseconds.… Read More »

How to move a body manually in Box2D? or Give a force to a body in Box2D, iPhone.

By | April 28, 2012

This is a sample code to move a body in Box2D . First you have to make a body with variable name “moving_rec” and call the below function in a schedular at regular intervals. -(void) moveBody{ b2Vec2 force = b2Vec2(0,0); force = b2Vec2(0,3); //Giving the x an y to negative will move the body in… Read More »

Using Tabbars in ANDROID, A Simple Example……….

By | April 22, 2012

This is a simple example showing how to use tabbars in ANDROID. First create a new project and copy this code to it. Now create three another java files by right clicking the src folder and name it FirstTab.java, SecondTab.java, ThirdTab.java. Now copy the following code to FirstTab.java. SecondTab.java Now ThirdTab.java. Main.xml file AndroidManifest.xml You… Read More »

Java Applet MouseEvents

By | April 22, 2012

A simple event based applet applications is described below First importing the necessary header files // Demonstrate the mouse event handlers. import java.awt.*; import java.awt.event.*; import java.applet.*; /* <applet code=”MouseEvents” width=300 height=100> </applet> */ Next step is to create a class which implements the “MouseListener” and “MouseMotionListener “ public class MouseEvents extends Applet implements MouseListener, MouseMotionListener {… Read More »

Date and TimePicker in ANDROID.

By | April 12, 2012

The following code simply allows you to select a date and time using the datepicker and timepicker in ANDROID.

Java check memory Allocation

By | April 7, 2012

When run the code the output will be similar to this Total memory is: 5177344 Initial free memory: 4986744 Free memory after garbage collection: 5063784 Free memory after allocation: 5045296 Memory used by allocation: 18488 Free memory after collecting discarded Integers: 5063784

How to find the device ID or Serial Number of an android device?

By | July 11, 2011

Here is a simple API to find the device ID of an android device. There are many ways to get the device ID in android Note : Try this in a real device, then only you will get the device ID. Also put this permission in the AndroidManifest file

Applet FlowLayout Example

By | May 16, 2011

The FlowLayout class puts components in a row, sized at their preferred size. Creates a new flow layout manager with the indicated alignment and the indicated horizontal and vertical gaps. The hgap and vgap arguments specify the number of pixels to put between components. The output window look like this

ANDROID Tabbars Example……..

By | May 9, 2011

This is a simple example showing how to use tabbars in ANDROID. First create a new project and copy this code to it. Now create three another java files by right clicking the src folder and name it FirstTab.java, SecondTab.java, ThirdTab.java. Now copy the following code to FirstTab.java. SecondTab.java Now ThirdTab.java. Main.xml file AndroidManifest.xml You… Read More »

Using Tabbars in ANDROID, A Simple illustration……….

By | May 9, 2011

This is a simple example showing how to use tabbars in ANDROID. First create a new project and copy this code to it. Now create three another java files by right clicking the src folder and name it FirstTab.java, SecondTab.java, ThirdTab.java. Now copy the following code to FirstTab.java. SecondTab.java Now ThirdTab.java. Main.xml file AndroidManifest.xml You… Read More »

Using Tabbars in ANDROID, A Simple Example……….

By | May 9, 2011

This is a simple example showing how to use tabbars in ANDROID. First create a new project and copy this code to it. Now create three another java files by right clicking the src folder and name it FirstTab.java, SecondTab.java, ThirdTab.java. Now copy the following code to FirstTab.java. SecondTab.java Now ThirdTab.java. Main.xml file AndroidManifest.xml You… Read More »

Listening incoming sms message in Android

By | May 1, 2011

When a new sms message is received by the device, a Broadcast Receiver is registered. For this IntentFilter filter = new IntentFilter(SMS_RECEIVED); registerReceiver(receiver_SMS, filter); should be included . Also sms are sent in PDU’s(Protocol Description Units) format, which act as an encapsulation. Inorder to extract from PDU to byte array messages[i] = SmsMessage.createFromPdu((byte[]) pdus[i]); method… Read More »

Showing Twitter updates on Blogger/Blogspot

By | April 24, 2011

Hi, If you want to show the latest twitter update of yours in your blogger/blogspot, then use the following steps. 1. Go to your blogger ‘Design’ 2. Click ‘Add A Gadget’ 3. Add ‘HTML/JavaScript’ 4. Paste the following JavaScript code into it and save 5. Done! Note : Replace ‘SampleURL’ with your twitter id &… Read More »

What is Objective C Keyword id ?

By | March 6, 2011

Hi, Objective C uses a special keyword ‘id’. Let’s see what it is. Objective C -id- is actually a ‘pointer to an object’. That is ‘id’ can hold a pointer to any objective c object. It doesn’t matter the object’s class. eg: NSString *myString = @”Coderz Heaven!”; id newString; NSString *tempString; newString=myString; tempString=newString; That’s it!… Read More »

Dynamically Load CSS in Adobe AIR/FLEX / Load css in Adobe AIR/FLEX using Class.

By | March 2, 2011

This example shows how to dynamically load css in Adobe AIR / FLEX. Here in this example Panel id the tag name for the panel control. Drag a panel control to your design then copy the code to your source file. “myTabs” is the class for the CSS. Panel { borderColor: #CBE0FF; border-style:solid; borderThickness: 1;… Read More »

How to detect shake Gesture in your iPhone Cocos2D?

By | February 26, 2011

For detecting shake in a cocos2D program copy these lines to your layer class bool shaked_once; //default false self.isAccelerometerEnabled = YES; [[UIAccelerometer sharedAccelerometer] setUpdateInterval:1/60]; shaked_once = false; Then copy this function to the same file…. and you are done…….. -(void) accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration { float THRESHOLD = 2; if (acceleration.x > THRESHOLD || acceleration.x… Read More »

Preventing Overriding in Java

By | February 25, 2011

Methods and variables can be ‘override’ in subclasses. (Yes, it’s a good feature too!). But what if we don’t want to ‘override’ our Methods and Variables in Java? It’s simple… Declare them using the keyword ‘final’ as modifier. That’s it. eg: So the value of myVariable can never be changed any way. Also for Classes/Methods.… Read More »

Creating Exceptions in JAVA

By | February 25, 2011

This is a simple custom exception in java. That is, we can create an exception by extending the exception class. The “throw new MyExcep” will throw an exception and the error message we specified will be displayed import java.lang.Exception; @SuppressWarnings(“serial”) class MyExcep extends Exception { MyExcep(String Errormsg) { super(Errormsg); // call Exception class error message… Read More »

Abstract Class in java

By | February 20, 2011

This example shows how a simple java abstract class works Here “Shape” is the abstract class abstract class Shape { abstract void initial(); // methods only defined….. abstract void display(); } class cube extends Shape { void initial() // Abstract Methods defined…. { System.out.println(“Hello !! “); } void display() { System.out.println(“How are you?”); } }… Read More »

Java Exception

By | February 19, 2011

Simple java program to show how exception works public class exception { public static void main(String[] args) { try { int a = 10; int b = 10/0; } catch(ArithmeticException e) { System.out.println(“Exception Caught ” + e); } } } The output will be like you expect Exception Caught java.lang.ArithmeticException: / by zero

Working with SQLite Database in ANDROID.

By | February 14, 2011

Below is a straight forward example of how to deal with SQLite database in ANDROID. Go ahead and copy and paste the following code to your java file. The example has one database and performs functions like insert delete and listing of values in a textView. In the XML file set up a TableLayout with… Read More »

How to remove unwanted frames from memory in iPhone?

By | February 13, 2011

In Cocos2D in iPhone often you may be using spritesheets which amy cause memory leaks because they are unused textures in memory even when you go from one scene to other. So make sure to remove all those unwanted textures from memory to save memory. Copy this following code to dealloc function in your class… Read More »