Tag Archives: methods

Playing sound on the Mac Desktop in Objective C.

By | March 11, 2011

There are different ways for playing sound on the Mac in Objective C. Let’s look at some of the methods.. 1. Play by filename. NSSound *mySound = [NSSound soundNamed:@”sound”]; if you have no file named “sound” in your application’s main bundle, then it will return nil. 2. Play by pathName sound = [[NSSound alloc] initWithContentsOfFile:@”/Volumes/Audio/sound.aiff” byReference:YES]; 3. Play… 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. eg: It will… 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?”); } } public class Abstract… Read More »

Detect when the ANDROID Screen Goes Off ?

By | January 18, 2011

This is the main Java file that extends activity. Create a file named ScreenON_OFF_ACTIVITY.java and place the below code in it. This is the class that extends the Broadcast receiver class that receives the notifications. create a java file and name it ScreenReceiver.java and place the following code in it. This the class that updates the service name… Read More »