Initiation au développement Android

Aller au contenu | Aller au menu | Aller à la recherche

lundi, mars 4 2013

Looking for graphist

For my new game development, I am looking for a graphic designer, a 3D modélisateur, a musician, for somebody interested to participate to the development.

If someone is interessed, please contact me at and send me some some of your realizations.


samedi, septembre 1 2012

Download Spacoid - not finalized version

In development on a new game with OPEN-GL, I decide finally to put in download the current version ( not finalized ) of Spacoid ( my first Java / Android development ), as well as the demo version of BugDash.


Spacoid V0.1 - Part1
Spacoid V0.1 - Part2
Spacoid V0.1 - Part3

BugDash V1.0 - Part1
BugDash V1.0 - Part2


I am opened to all your remarks either with comments directly on this site, or by e-mail at

mercredi, août 31 2011


According to the development, I am going to present here, my researches, the difficulties, the various solutions and thoseadopted and the source code. I begin in programming Java, as well as in programming Android. All the remarks, the helps, the criticism (the least possible I hope), will be welcome if it is constructive and if it advances the project, the site or the understanding of certain problems. Should the opposite occur, if it is to criticize for criticizing, or not constructive criticism, go to visit somewhere else.

The e-mail address was dedicated to any communications in touch with this site. Do not hesitate to write me. All the constructive e-mails will be read. However, I would not certainly answer everybody.


Project creation

Splash Screen


Creation of the directory " C:\Android " in which we are going to install everything.

For the installation of the eCLIPSE development environment, we extract the directory " eclipse ", contained in the zip file, in the directory c:\Android. Http://

Also for the installation of the Android SDK, we extract the directory " android-sdk-windows ", contained in the zip file, in the directory c:\Android. Http: //

For the development, the JDK Java has to be installed.

It is then necessary to add the path of the SDK in the PATH variable of your system. For that purpose, click with the right button on your workstation icon, then go to the tab " Advanced Parameters ". Click the button " Variables of environment ", edit the variable system " PATH ", and add at the end of line the path towards the directory " tools " of the SDK Android. In our case, add "; c:\Android\android-sdk-windows " and apply.

We have to integrate the Android plugin into Eclipse. Execute the Eclipse software (the first execution may be long ). Go to the menu "Help / software Updates..." Go to the tab " Available Software ". Click " Add Site... " Enter the following address: or, then click on OK.

Return on the tab " Available Software " Select Android components to be installed, then click "Install". In the following window, click "Next". Accept " license agreement "; and click "Finish". Finally, restart Eclipse.

If an error arose with the automatic download of the plugin Android, you can download directly the file (or a more recent version) from the address You save this file in the directory " C:\Android\download "

You start in the stage Click "Add Site", to the right of the fields where you inform the address, click the button "Archives" and select the file previously loaded, " C:\Android\download\ ". Then resume the following stages to finalize the installation of the plugin Android.

Project creation

Select "File/New/Project". Select the type of project "Android", then make "Next". In the window which appears, inform: "Project Name": name of the project. "Package Name": specify the name of the Java package. The fact of creating "Activity" requires to specify the name of the class which will be initial Activity and name of the application "Application Name". "Min SDK version" allows to specify the minimun version of the SDK on which the application will work.

The Android version 1.6 ( Donut) is version 4. The 2.0 (Eclair) SDK is version 5. The 2.1 is version 7 … For more information, see

He may arrive that the list of the various versions of Android is empty, what blocks for the creation of the project. Leave the creation of the project, and go to "Windows/Preference". Select "Android", in the right window, inform "SDK Location :" with the complete path to reach the SDK Android

You can relaunch the creation of the new project, the list is now informed.

Emulator definition

1. Emulator definition

In Eclipse/Windows menu , select "Android SDK and AVD manager"


Click on "New", this window opens :


Inform the diverse fields as above, for example, and click "Create AVD". The creation can take certain time, then be patient. When the creation of the new emulator is realized, you are taken back on the previous window.


You can now select the created emulator and start it up by pressing on "Start". The following window opens, click directly "Launch".


The window of the emulator opens.


And then after Android is started.


Splash Screen

We are going to begin the application with a presentation screen, called splash screen. This screen will allow us afterward to pre-load a lot of resources used during the application. This presentation screen will not appear when you will click the previous button, it will leave simply the application without re-posting this screen.

Thus we are going to show an image during a few moments before showing the main menu of the game.

We are going to resume(to take back) the tutorial of barebonescoder at the address : ) .

We begin by creating the “splashscreen.xml” file which will describe what must be shown on our screen. For that purpose, on the layout item of our project, with the right button, we make new / file to add a XML file which we name splashscreen.xml. In this file, we add the following code:

<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="" android:gravity="center_horizontal|center_vertical" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/spacoid"> <TextView android:layout_height="wrap_content" android:text="LOADING" android:id="@+id/textView1" android:layout_width="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge"/> </LinearLayout>

With this code, we add a LinearLayout in which we position in background our presentation image "@drawable / spacoid".

We are going to update the file AndroidManifest, to define correctly the screen of our application.

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android=""

   <uses-sdk android:minSdkVersion="4" />
   <application android:icon="@drawable/icon" android:label="@string/app_name">
       <activity android:label="@string/app_name"

android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:screenOrientation="portrait" android:name="SplahScreenActivity">

               <action android:name="android.intent.action.MAIN" />
               <category android:name="android.intent.category.LAUNCHER"/>


Il ne reste plus qu’à ajouter le code permettant l’affichage de cet écran de présentation avec le code suivant :

With the following lines:

android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:screenOrientation="portrait"

we force the display in portrait mode, as well as the display in full screen by eliminating the status bar at the top of the screen.

It remains to add the code allowing the display of this presentation screen with the following code:

package com.jeux.splashscreen;

import; import android.os.Bundle;

public class SplahScreenActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate( Bundle savedInstanceState ) { // Must be first instruction of onCreate. super.onCreate( savedInstanceState ); // Show Splash screen. setContentView( R.layout.splashscreen ); // Create and run thread. Thread splashThread = new Thread() { @Override public void run() { try { int waited = 0;

while( waited < 5000 ) { sleep( 50 ); waited += 100; } } catch( InterruptedException e ) { e.printStackTrace(); } finally { finish(); } } }; splashThread.start(); } }

After execution, we obtain the following display, during some seconds, then the application ends:


Download corresponding archive.

Main Menu

In this new episode, we are going to take care of the general menu of the game, which will appear after the presentation screen and will look like this:


We begin by creating in the directory « res / layout », a new file named « mainmenu.xml », in which we define the background of screen, the title and 4 buttons, in the following way:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android=""

We create a LinearLayout which will contain the various objects, with the attribute android:gravity positioned in center_horizontal, to center objects one under the other, and in which we put our background image "@drawable / main_screen". We add a first "ImageView" to show the image of the name of the game. We put a second "ImageView" empty to leave a space between the title and the buttons below. Then we define 4 buttons with attribute "android:onClick" informed with the name of the function managing the action of the button.

In « res/values »,, we add diverse definitions and diverse identifiers,

In « res/values/dimens.xml » :

    <dimen name="gfont_en_font_h">18.0px</dimen>
    <dimen name="main_button_width">100.0dp</dimen>
    <dimen name="main_layout_y">80.0px</dimen>

In « res/values/ids.xml » :

    <item type="id" name="highscore_title">false</item>
    <item type="id" name="main_play_button">false</item>
    <item type="id" name="main_options_button">false</item>
    <item type="id" name="main_highscore_button">false</item>
    <item type="id" name="main_quit_button">false</item>

In « res/values/strings.xml » :

<?xml version="1.0" encoding="utf-8"?>
    <string name="app_name">Spacoid</string>
    <string name="main_highscore">High Scores</string>
    <string name="main_options">Options</string>
    <string name="main_play">Play</string>
    <string name="main_quit">Quit</string>

We update the file AndroidManifest.xml to define the new activity which will open to show the main menu of the game.

<?xml version="1.0" encoding="utf-8"?>
    <uses-sdk android:minSdkVersion="4" />
               <action android:name="android.intent.action.MAIN" />
               <category android:name="android.intent.category.LAUNCHER"/>

Finally we create a new class which will post the menu and will manage the various buttons. In « src/com.jeux.mainmenu », we create the new file, which will contain:

package com.jeux.mainmenu;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

public class MainMenu extends Activity {
	public void onCreate(Bundle savedInstanceState) {

	public void main_play_button_onClick(View v){}

	public void main_options_button_onClick(View v){}

	public void main_highscore_button_onClick(View v) {}

	public void main_quit_button_onClick(View v)

In the « onCreate » function, we show the layout " R.layout.mainmenu " corresponding to the display. Then we create a function for every callback associated with the present buttons in the menu:

main_play_button_onClick This function will be called on the selection of the button " Play " and will launch the game. main_options_button_onClick This function will be called on the selection of the button "Options" and will allow to reach the options of sound, RAZ of the score and some information on the game. main_highscore_button_onClick This function will be called on the selection of the button " High Scores " which will show the high scores screen. main_quit_button_onClick This function will be called on the selection of the button " Quit " which will end the activity and will leave the application.

download archive.