Monday, April 23, 2012

Override the Device's Back button

When browsing a game's Options Menu and decided to not modify the current settings,  you simply want to use your phone's Back button as, well, for going back to Main Menu.

But sadly, this is not the default behavior of that Back button.  When you try to create your game, pressing that button will quit (umm... hide, rather) your app.

But don't lose hope.  There's actually a way of changing that default behavior.

On your app's Activity class, add the following snippet.

@override
public void onBackPressed() {
   if (state == STATE_MAINMENU) {
      super.onBackPressed();
   } else {

      //do something else
   }
}


Of course, both state and STATE_MAINMENU has to be defined for the snippet to be usable.  Also, whatever new behavior you want the Back button will have to do will be coded on the else part of the snippet, as indicated by do something else.

(via Creek Codes)

Saturday, April 21, 2012

Keep Screen in Portrait Mode


By default, your app will run in Portrait mode.  And you might opt to keep it that way, but would also rotate to Landscape mode if the phone it handled sideways.

To keep it in Portrait mode, open your AndroidManifest.xml then add the highlighted text below.

<activity
   android:label="@string/app_name"
   android:name="HelloWorld"
   android:screenOrientation="portrait" >
   ...
< /activity>

But if you are creating an Android game, chances are you wanted to default it in Landscape and stay that way. If so, just change portrait to landscape.


(via Creek Codes)

Wednesday, July 14, 2010

App Inventor available for testing

There's a new tool in town that let's you create Android app in an instant.

Primarily designed for non-programmers, the tool can create apps with minimal code or non-coding at all.

Google has unvailed App Inventor on its Google Labs. It is currently available for beta testing. Filing an application to test is required.

View the demo below.

Saturday, June 12, 2010

Replica Island: Open Source Android Game

Recently bumped into an open source game intentionally developed for Android platform, which was started way back August 2009.



Replica Island is developed by an Android evangelist and Google employee, Chris Pruett. His blog discusses every little detail of the approach he did for this game. It would really be a good source of information about Android Game Development.

Get the source code at Google Code.

The game is already out in the Android Market so if you have your Android phone with you right now, I recommend that you try the game and see for yourself.

Wednesday, February 17, 2010

Where is the Color class?

Same case with Point2D, Java's usual Color class which should be under java.awt package could be found under Android's android.graphics package.

They needed to remove some functionality of the class thus came need to replace the usual Color class. Methods such as brighter and darker were removed.

JASAfA's Color class
Progress with JASAfA has been going smoothly. ActionScript's Color class is called which is accessible under ColorTransform flash.geom package. Likewise, JASAfA's Color class is accessible under droid.geom package.

Tuesday, February 16, 2010

Adobe AIR coming to Android Soon

In the currently being held Mobile World Congress in Barcelona, the Adobe Air Team previewed AIR applications running on Android and promised to bring Flash 10.1 in the first half of the year.

With Adobe AIR, developers can deliver rich and "more immersive" applications outside the mobile browser and across multiple operating systems. This will enable a write once and deploy anywhere solution for mobile and web applications.

Flash 10.1 will be completed within the first half of this year, while also including support for WebOS, Symbian, Windows Mobile and BlackBerry devices.

Friday, February 12, 2010

Alternative to Point2D

Given that AWT is not supported in Android API, the Point2D class, which is useful for writing 2D graphics, is missing either.

Point2D is traditionally accessible under java.awt.geom package but not dependent on the AWT framework so why was it not included in Android API? The answer is, Android have Point and PointF classes. Although among the two, PointF is my personal favorite.

Other Point class alternative
I've introduced JASAfA earlier, which happens to have another Point class which works like its ActionScript-counterpart. JASAfA's Point class is accessible under droid.geom package.