Week #11 Challenge: Android

  • (2 Pages)
  • +
  • 1
  • 2

17 Replies - 19044 Views - Last Post: 24 March 2010 - 04:08 AM

#1 Core  Icon User is offline

  • using System.Linq;
  • member icon

Reputation: 773
  • View blog
  • Posts: 5,097
  • Joined: 08-December 08

Week #11 Challenge: Android

Post icon  Posted 14 March 2010 - 03:14 PM

Week #11: Android

Posted Image

Challenge submitted by gabehabe

CHALLENGE:
Develop a simple application & interface for an android application. Whether you enjoy programming in Java or not, using the Android SDK still makes it fun!

You don't need an Android phone to try this challenge. The SDK comes with an emulator!

INTRODUCTION TO ANDROID:
Android, as you all probably know, is Google's mobile handset operating system, introduced in 2008, as the first major competitor to the iPhone OS. Unlike iPhone OS, however, Android is available on a plethora of different devices, with different specs, different hardware, etc. Certain manufacturers have even customised Android to suit their handset, such as HTC's "Sense" UI, available on the Hero, Legend, Desire, and many more. In the last year, Android has begun to spread from just being a mobile operating system onto other platforms, particularly netbooks.

IDEAS:
  • Tabbed note editor (To my knowledge, there isn't even one of these on the market!)
  • GUI calculator
  • Shopping list
  • Twitter client
  • Weather widget
  • Calendar/diary application



RESOURCES:



HOW TO GET STARTED:
Getting set up for using Android is a relatively simple task, you can download the SDK from here. From there, you will also find a link to download the eclipse IDE, for which there are many tools & plugins for debugging & getting the best out of your Android application.

WHERE TO GO FOR HELP:
If you're struggling, you can get help from Dream.In.Code's Mobile Development forum, or from anddev, a thriving Android development community.

Is This A Good Question/Topic? 0
  • +

Replies To: Week #11 Challenge: Android

#2 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1524
  • View blog
  • Posts: 5,957
  • Joined: 21-March 08

Re: Week #11 Challenge: Android

Posted 15 March 2010 - 03:21 AM

i have released an app for Android, but I might do another small one.

the app I released is called MotoTorch LED. It's only for the Motorola Droid and the Motorola Milestone. It uses the camera LED as a flashlight, strobe light, and does morse code.

This post has been edited by eclipsed4utoo: 15 March 2010 - 03:22 AM

Was This Post Helpful? 0
  • +
  • -

#3 Shane Hudson  Icon User is offline

  • D.I.C Technophile
  • member icon

Reputation: 342
  • View blog
  • Posts: 1,286
  • Joined: 06-December 09

Re: Week #11 Challenge: Android

Posted 15 March 2010 - 05:08 AM

I do not have an Android, are there any emulators for testing it?
Was This Post Helpful? 0
  • +
  • -

#4 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1524
  • View blog
  • Posts: 5,957
  • Joined: 21-March 08

Re: Week #11 Challenge: Android

Posted 15 March 2010 - 05:54 AM

View PostShane Hudson, on 15 March 2010 - 07:08 AM, said:

I do not have an Android, are there any emulators for testing it?


yes, an emulator comes with the SDK.

here is another resource...

http://developer.and...clipse-adt.html

It shows how to install the ADT plugin with Eclipse.
Was This Post Helpful? 0
  • +
  • -

#5 Denis1  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 32
  • View blog
  • Posts: 101
  • Joined: 29-July 09

Re: Week #11 Challenge: Android

Posted 15 March 2010 - 02:27 PM

Whoooo yes this is the best challage yet. i love the android :w00t: :rockon: :bananaman: :gun_bandana:
Was This Post Helpful? 0
  • +
  • -

#6 Dogstopper  Icon User is offline

  • The Ninjaducky
  • member icon



Reputation: 2857
  • View blog
  • Posts: 10,960
  • Joined: 15-July 08

Re: Week #11 Challenge: Android

Posted 15 March 2010 - 04:00 PM

I completely no-lifed my day today learning all about Android, and me being the Java person that I am, picked it up really quickly. Thanks gabehabe!

I have been following a series of online Graphics tutorials now in the hopes of creating a game. Well, on my first day, I walk home with an application that moves a custom image of mine to wherever I click.

Here's the 3 classes:
TestGraphics2D.java (main method)
package com.thousandcodes.graphics2D;

import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.os.Bundle;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.Window;

public class TestGraphics2D extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(window.FEATURE_NO_TITLE);
        setContentView(new Panel(this));
    }
}



Panel.java (The panel on which all is drawn)
package com.thousandcodes.graphics2D;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceView;

public class Panel extends SurfaceView 
	implements SurfaceHolder.Callback 
{
	private GraphicsThread thread;
	
	private int x = 20;
	private int y = 20;
	
	public Panel(Context con) {
		super(con);
		getHolder().addCallback(this);
		thread = new GraphicsThread(getHolder(), this);
		setFocusable(true);
	}
	
	@Override
	public void onDraw(Canvas can) {
		Bitmap basic = BitmapFactory.decodeResource(getResources(), R.drawable.heroship);
		can.drawColor(Color.BLACK);
		can.drawBitmap(basic, x - (basic.getWidth()/2), y - (basic.getHeight()/2), null);
	}

	@Override
	public void surfaceChanged(SurfaceHolder holder, int format, int width,
			int height) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void surfaceCreated(SurfaceHolder holder) {
		thread.setRunning(true);
		thread.start();		
	}

	@Override
	public void surfaceDestroyed(SurfaceHolder holder) {
		// To prevent access to the screen after the program
		// is done using it, we wait for it to be done...		
		boolean retry = true;
		thread.setRunning(false);
		while (retry) {
			try {
				thread.join();
				retry = false;
			} catch (InterruptedException e) {
				continue;
			}
		}	
	}
	
	@Override
	public boolean onTouchEvent(MotionEvent event) {
		x = (int)event.getX();
		y = (int)event.getY();
		return true;		
	}
}



GraphicsThread.java (The main loop occurs in its own thread)
package com.thousandcodes.graphics2D;

import android.graphics.Canvas;
import android.view.SurfaceHolder;

public class GraphicsThread extends Thread {
	private SurfaceHolder holder;
	private Panel panel;
	private boolean gameRunning = false;
	
	public GraphicsThread(SurfaceHolder sh, Panel p) {
		holder = sh;
		panel = p;
	}
	
	public void setRunning(boolean r) {
		gameRunning = r;
	}
	
	@Override
	public void run() {
		Canvas c;
		while (gameRunning) {
			c = null;
			try {
				c = holder.lockCanvas(null);
				// Must synchronize at least the drawing to the screen.
				synchronized(holder) {
					panel.onDraw(c);
				}
			} finally {
				if (c != null) {
					// Ensures that even if an error occurs, that we release the screen
					holder.unlockCanvasAndPost(c);
				}
			}
		}
	}
}



It is compatible with Android 2.0.
Here are the screenshots.
Before click:
Attached Image

After click:
Attached Image
Was This Post Helpful? 2
  • +
  • -

#7 Raynes  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 610
  • View blog
  • Posts: 2,815
  • Joined: 05-January 09

Re: Week #11 Challenge: Android

Posted 15 March 2010 - 08:02 PM

Makes me wish I had an Android phone. I'd totally be hacking this up in Clojure.
Was This Post Helpful? 0
  • +
  • -

#8 skyhawk133  Icon User is offline

  • Head DIC Head
  • member icon

Reputation: 1858
  • View blog
  • Posts: 20,275
  • Joined: 17-March 01

Re: Week #11 Challenge: Android

Posted 15 March 2010 - 08:31 PM

View PostRaynes, on 15 March 2010 - 07:02 PM, said:

Makes me wish I had an Android phone. I'd totally be hacking this up in Clojure.


The SDK comes with an emulator.... what does Clojure have to do with this challenge?
Was This Post Helpful? 0
  • +
  • -

#9 YamNad  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 9
  • View blog
  • Posts: 120
  • Joined: 11-July 09

Re: Week #11 Challenge: Android

Posted 16 March 2010 - 06:36 AM

View Postskyhawk133, on 16 March 2010 - 03:31 AM, said:

The SDK comes with an emulator.... what does Clojure have to do with this challenge?


The Android SDK is usable from Clojure.
Was This Post Helpful? 0
  • +
  • -

#10 skyhawk133  Icon User is offline

  • Head DIC Head
  • member icon

Reputation: 1858
  • View blog
  • Posts: 20,275
  • Joined: 17-March 01

Re: Week #11 Challenge: Android

Posted 16 March 2010 - 07:11 AM

Perfect, so no excuses Raynes.......
Was This Post Helpful? 1
  • +
  • -

#11 programble  Icon User is offline

  • (cons :dic :head)

Reputation: 49
  • View blog
  • Posts: 1,315
  • Joined: 21-February 09

Re: Week #11 Challenge: Android

Posted 16 March 2010 - 12:12 PM

View Postskyhawk133, on 15 March 2010 - 09:31 PM, said:

View PostRaynes, on 15 March 2010 - 07:02 PM, said:

Makes me wish I had an Android phone. I'd totally be hacking this up in Clojure.


The SDK comes with an emulator.... what does Clojure have to do with this challenge?


Doesn't any JVM language have a lot to do with this?

This post has been edited by programble: 17 March 2010 - 01:44 PM

Was This Post Helpful? 0
  • +
  • -

#12 Raynes  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 610
  • View blog
  • Posts: 2,815
  • Joined: 05-January 09

Re: Week #11 Challenge: Android

Posted 16 March 2010 - 09:25 PM

View Postskyhawk133, on 15 March 2010 - 07:31 PM, said:

View PostRaynes, on 15 March 2010 - 07:02 PM, said:

Makes me wish I had an Android phone. I'd totally be hacking this up in Clojure.


The SDK comes with an emulator.... what does Clojure have to do with this challenge?


Just as much as Java has to do with this challenge. http://github.com/remvee/clj-android


View Postskyhawk133, on 16 March 2010 - 06:11 AM, said:

Perfect, so no excuses Raynes.......


I don't really want to write an application that I can't even use. Until I have an Android phone, this challenge doesn't really contribute anything useful to me. I may do it when I don't have any projects of my own to keep me busy, but I don't think I'll be getting it done this week. This is a great challenge, and sounds really fun, and the only excuse I have is "I don't want to do it right now."

I'm sorry if that isn't an acceptable excuse.
Was This Post Helpful? 0
  • +
  • -

#13 TheAKB  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 2
  • View blog
  • Posts: 59
  • Joined: 11-November 08

Re: Week #11 Challenge: Android

Posted 17 March 2010 - 02:21 PM

Hmmmmm seems intresting i dont have an android phone but think im gonno have a go at this one anyway, downloading now so hopefully have something to show soon.
Was This Post Helpful? 0
  • +
  • -

#14 skyhawk133  Icon User is offline

  • Head DIC Head
  • member icon

Reputation: 1858
  • View blog
  • Posts: 20,275
  • Joined: 17-March 01

Re: Week #11 Challenge: Android

Posted 17 March 2010 - 02:54 PM

Remember, the goal of these challenges if for you to try new things. Just because you don't have a need for it, doesn't mean there isn't value in trying it. It may turn you on to a whole new arena that you never realized you enjoyed.
Was This Post Helpful? 1
  • +
  • -

#15 Dogstopper  Icon User is offline

  • The Ninjaducky
  • member icon



Reputation: 2857
  • View blog
  • Posts: 10,960
  • Joined: 15-July 08

Re: Week #11 Challenge: Android

Posted 17 March 2010 - 02:57 PM

Exactly, I have to really thank this challenge for finding me a new hobby. I never realized how fun Game Design is for phones! It's actually quite difficult since the hardware is unfamiliar.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2