Hello, Android

Ed Burnette

Mentioned 6

Provides information on the basics of Androd programming, covering such topics as designing the user interface, 2D graphics, multimedia, storing local data, SQL, OpenGL, and multi-touch.

More on Amazon.com

Mentioned in questions and answers.

I am a recent computer science student and have intermediate knowledge of java. However I am good at PHP.

Please suggest me a fastest way to learn Android and start developing apps immediately.

Pick up a book such as Hello Android. It's an easy read to skim through to pick up the basics of Android. I also bought this book buy Reto Meier.

You can also learn a lot by reading some of the more popular questions on Stackoverflow tagged Android.

Poke around some open source projects. There are some popular ones such as FourSquare that you can look at. Here is a list on Wikipedia.

I also wrote about some of my first experiences on Android here with my open source app.

I'm familiar with Java but am just starting out Android programming, and don't really know what I need to make things happen. I'm trying to work with a Canvas, I'm basically making an app that reads real-time data and makes a constantly changing graph based off of it, with some buttons and other interactive UI. What are the methods I need to implement? For example, in "regular" Java, I know I would NEED to have

public void init(){//...}
public void paint(Graphics g) {//...}
public void run(){//...}
public static void main (String argv[]) {//...}
//...and more

Based on sample code that I found it seems like I need the following general outline (plus my own miscellaneous functions and classes).

public class MyClass extends Activity{
    public void onCreate(Bundle savedInstanceState){//initialization and setup}
    public class MySurfaceView extends SurfaceView implements Runnable{
        public MySurfaceView(Context context){//constructor}
        public void onResumeMySurfaceView(){//???}
        public void onPauseMySurfaceView(){//deal with user leaving the activity}
        public void run(){//...}
        public boolean onTouchEvent(){//...}

Do I need all of these? What more/else do I need? And, what goes in each of the methods (e.g., where does the stuff I would normally put in paint(Graphics g) go)?

I realize this is a very general question that's kind of big, and would appreciate either tips or a link to a tutorial that is more specific than, say, http://developer.android.com/reference/android/app/Activity.html

i saw the code of starting other apps from my app.but i understood little bit ..i need some detailed ebooks on intents and start activity ON ANDROID...

this is the book I used to learn about Android. It walks you through code and how to build apps but long before it goes into detail about the architecture and what you spefically asked for (intents and activities). It's really good and explains all the code and what each line does, and also helps you install and set up Eclipse (which I found to be quite difficult).


Hope this is what you meant by your question. Had a hard time understanding :P

I want to create a board game (9x9 grid) for the android. I was wondering if there where any suggestions as to books, blogs, tutorial, or even open source programs to look into.

I was planning on writing the majority of it in native java/c++. probably with a target of API level7 platform 2.1 update 1 (as this is an actual device I have access to)

I am mostly interested in displaying the board, tiles, and pieces (I already have a some assets that can be re-sized if needed) to the screen, and if I can find something that will help me understand how to register movement of the pieces that would be amazing to.

The book Hello, Android guides you through the development of a game which has a 9x9 grid, Sudoku. The author's implementation of the grid is simple and easy to follow. The book is a decent read for beginners.

this is my first question on Stack Overflow and is has to do with the builder pattern for an Android dialog. I recently started reading through the book Hello Android 3rd Edition to learn how to build a basic Android application. I have basic Java experience (two intro programming courses and one data structures/algorithms class all with homework in Java), but am not familiar with builder patterns or Android in general yet.

I am getting a WindowLeaked error when executing the .show() command for the alert dialog builder in the openNewGameDialog() method shown below. I broke up the method into individual calls on the builder to identify which one was the source of the error:

// Creates a selection for game difficulty
private void openNewGameDialog() {
    AlertDialog.Builder builderDifficulty = new AlertDialog.Builder(this);
        new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialogInterface, int i) {
    builderDifficulty.show(); // Throws an error

I researched the problem I am having elsewhere on this site, but for the most part it appears that people are getting problems where they have not correctly dismissed the dialog. I don't think that the same problem is occurring for me, but I am not familiar with dialogs or builders like this, so I could be mistaken. The code is taken directly from an example in the book, so I was expecting it to work properly.

I am emulating a Nexus 5 with Android 4.4.2 to test the program. Here is the error text from LogCat:

06-18 15:37:05.260: E/WindowManager(1089): android.view.WindowLeaked: Activity book.example.sudoku.MainActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView{b1dfa088 V.E..... R....... 0,0-1026,684} that was originally added here
06-18 15:37:05.260: E/WindowManager(1089):  at android.view.ViewRootImpl.<init>(ViewRootImpl.java:348)
06-18 15:37:05.260: E/WindowManager(1089):  at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:248)
06-18 15:37:05.260: E/WindowManager(1089):  at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69)
06-18 15:37:05.260: E/WindowManager(1089):  at android.app.Dialog.show(Dialog.java:286)
06-18 15:37:05.260: E/WindowManager(1089):  at android.app.AlertDialog$Builder.show(AlertDialog.java:951)
06-18 15:37:05.260: E/WindowManager(1089):  at book.example.sudoku.MainActivity.openNewGameDialog(MainActivity.java:72)
06-18 15:37:05.260: E/WindowManager(1089):  at book.example.sudoku.MainActivity.onClick(MainActivity.java:54)
06-18 15:37:05.260: E/WindowManager(1089):  at android.view.View.performClick(View.java:4438)
06-18 15:37:05.260: E/WindowManager(1089):  at android.view.View$PerformClick.run(View.java:18422)
06-18 15:37:05.260: E/WindowManager(1089):  at android.os.Handler.handleCallback(Handler.java:733)
06-18 15:37:05.260: E/WindowManager(1089):  at android.os.Handler.dispatchMessage(Handler.java:95)
06-18 15:37:05.260: E/WindowManager(1089):  at android.os.Looper.loop(Looper.java:136)
06-18 15:37:05.260: E/WindowManager(1089):  at android.app.ActivityThread.main(ActivityThread.java:5017)
06-18 15:37:05.260: E/WindowManager(1089):  at java.lang.reflect.Method.invokeNative(Native Method)
06-18 15:37:05.260: E/WindowManager(1089):  at java.lang.reflect.Method.invoke(Method.java:515)
06-18 15:37:05.260: E/WindowManager(1089):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
06-18 15:37:05.260: E/WindowManager(1089):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
06-18 15:37:05.260: E/WindowManager(1089):  at dalvik.system.NativeStart.main(Native Method)

Any help would be appreciated!

So I'm starting an android project, very new to it and to java. But I have a knowledge in programming, especially VB.

I'm planning to create and app for certain users to see the data from a database. Is it possible without an internet connection? If not, will be a difficult task?

Where is the database? Is it online? When you say "Data Connection" do you mean Edge/4G/LTE or WiFi or Bluetooth? Your device has to connect at least once to the database in order to copy over the required data, and it depends on the database, but you might as well just copy it locally all over to the device itself.

Here are few starting points:

I also recommend getting this book for beginners (try Google-ing it, you know...) . It was very helpful for me to use it. In about a week (if you are fast like that) you can have a pretty solid experience and understanding.