Your opinion...

General Android Books.
Also feel free to comment, improve and contribute to AndBook, the free Android Learners book.

Postby yphuan » Wed Mar 26, 2008 7:54 pm

Good!

Thanks "+-"
yphuan
Once Poster
Once Poster
 
Posts: 1
Joined: Sun Feb 24, 2008 4:04 pm

Top

Postby venkat » Thu Mar 27, 2008 9:15 am

I like this guide very much. :)
Regards,
Venkat.
venkat
Senior Developer
Senior Developer
 
Posts: 152
Joined: Tue Nov 27, 2007 5:42 am
Location: India

Postby Stephen.Ada » Sun Apr 20, 2008 8:31 am

How to be a member of the contributors? 8) 8) 8) 8) 8)
Stephen.Ada
Junior Developer
Junior Developer
 
Posts: 10
Joined: Mon Mar 10, 2008 3:18 pm

Postby plusminus » Mon Apr 21, 2008 8:09 am

Stephen.Ada wrote:How to be a member of the contributors? 8) 8) 8) 8) 8)


Contact me :)
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby dexter » Tue Jun 24, 2008 1:57 pm

hey +/-,

have been following ur post and forum for quite sometime and wantedto say thnxs coz of u may be me and my company can get some early projects on android.

i just downloaded ur book and it looks kool but it seems to be a early a draft. i would like to contribut some to it but dont know how farr are u on to it.. can u let me know about what is the current version of this book. i havae with me the very first version.
dexter
Freshman
Freshman
 
Posts: 7
Joined: Mon Jun 16, 2008 7:18 am

Postby borya » Thu Jul 03, 2008 11:30 pm

I just read the whole thing. I wish I had this when I was just starting to wade through the official documentation!
borya
Developer
Developer
 
Posts: 27
Joined: Wed Jul 02, 2008 7:50 pm
Location: California, USA

Top

Postby gymshoe » Wed Sep 10, 2008 6:13 am

Excellent book so far. (I am very new to Android...)
I do have a possible error pg 53.

Your code:
Intent i = new Intent( StartingSubactivities.this, MySecondActivity.class);

The Eclipse IDE will not compile this becuase it says "StartingSubactivities" is not declared and I can't figure out how to fix this. (I notice that the package is called ".startingsubactivities" so I tried it without the capital letters but that didn't fix it). It doesn't seem to be a standard method unless I missed something...

thanks,
jim
gymshoe
Junior Developer
Junior Developer
 
Posts: 15
Joined: Wed Sep 10, 2008 6:07 am

Postby plusminus » Wed Sep 10, 2008 12:59 pm

gymshoe wrote:Excellent book so far. (I am very new to Android...)
I do have a possible error pg 53.

Your code:
Intent i = new Intent( StartingSubactivities.this, MySecondActivity.class);

The Eclipse IDE will not compile this becuase it says "StartingSubactivities" is not declared and I can't figure out how to fix this. (I notice that the package is called ".startingsubactivities" so I tried it without the capital letters but that didn't fix it). It doesn't seem to be a standard method unless I missed something...

thanks,
jim


Hello jim,

"[font=Courier New]StartingSubactivities[/font]" is the name of the class you are working in. Maybe you called it a bit different.

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby gymshoe » Fri Sep 12, 2008 7:53 pm

Yes, I am sure you are right. Nevertheless, I have to say you have lost me on this very important Android concept of calling subactivities with Intents.
I am very new to Android (and hopefully reasonable intelligent), so perhaps I am a good "guinea pig" for your book, but in any case I am lost.

I was following the directions in your book very closely while coding in eclipse at the same time. However, I don't see where you ever declare StartingSubactivities. (I also searched the *.pdf file to be sure that I didn't miss it...) You do declare the package "startingsubactivities" but given the case-sensitive nature of Android, this shouldn't be the same thing. You also declare MySecondActivity, but that is the only class or method (that isn't an override) that you declare explicity in the text of your book.
Furthermore, you use the method "startSubActivity()", but I do not see where you have declared this method either in your book. Moreover, I cannot find a reference to this method in the android SDK, either. I can find the method startActivity, which has 4 constructors, but none of them take arguments (intent,int) like you have here. (The android method startActivityForResult(Intent, int) takes the arguments you have specified...) So I suspect that startSubActivity() is a method that I was so supposed to declare as well, but since I am rather new to Android, what goes in this method?


Thank you for any guidance.

Jim
gymshoe
Junior Developer
Junior Developer
 
Posts: 15
Joined: Wed Sep 10, 2008 6:07 am

Postby gymshoe » Sat Sep 13, 2008 8:48 pm

I now have it figured out. The issue I had with StartingSubactivities was just me being a "novice"...

However there are other discrepancies like the startSubActivity one I mentioned, that I couldn't get to work.
For instance (pg 56) you refer to "setResult(1, keyword)".
The setResult() method for Activity does not have any constructors accepting (int, string) arguments. Also on pg56, you refer to "onActivityResult(int,int,string,bundle)" but this method only has constructors accepting (int,int,Intent) arguments. Your code for "URI.parse..." on pg57 also didn't work as written.

Perhaps these are issues with the M5 to 0.9 conversion? (but I know even less about M5 than 0.9...).

Anyway, I think the following code addresses the issues described and works in SDK0.9:



Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. package org.anddev.andbook.startingsubactivities;
  2.  
  3.  
  4.  
  5. import android.app.Activity;
  6.  
  7. import android.content.Intent;
  8.  
  9. import android.net.Uri;
  10.  
  11. import android.os.Bundle;
  12.  
  13. import android.view.View;
  14.  
  15. import android.view.View.OnClickListener;
  16.  
  17. import android.widget.Button;
  18.  
  19. import android.util.Log;
  20.  
  21.  
  22.  
  23. public class MainActivity extends Activity {
  24.  
  25.         public static final String MY_DEFAULTSTRING_ID = "defStrID";
  26.  
  27.         private static final int MYSECONDACTIVITY_REQUESTCODE = 0x1337;
  28.  
  29.  
  30.  
  31.         /** Called when the activity is first created. */
  32.  
  33.     @Override
  34.  
  35.     public void onCreate(Bundle savedInstanceState) {
  36.  
  37.         super.onCreate(savedInstanceState);
  38.  
  39.         setContentView(R.layout.main);
  40.  
  41.  
  42.  
  43.         /* Find the Button from our XML-layout. */
  44.  
  45.         Button b = (Button)this.findViewById(R.id.btn_open_search);
  46.  
  47.         b.setOnClickListener(new OnClickListener(){
  48.  
  49.                 public void onClick(View arg0) {
  50.  
  51.                 // Place code to handle Button-Click here.
  52.  
  53.                 // Create an Intent to start MySecondActivity. */
  54.  
  55.                 Intent i = new Intent(
  56.  
  57.                                 MainActivity.this, MySecondActivity.class);
  58.  
  59.                 //* Create a bundle which will be attached to the Intent, to carry
  60.  
  61.                 //* information to our MySecondActivity. */
  62.  
  63.                 Bundle b = new Bundle();
  64.  
  65.                 b.putString(MY_DEFAULTSTRING_ID, "www.google.com");
  66.  
  67.                 //* Attach Bundle to our Intent. */
  68.  
  69.                 i.putExtras(b);
  70.  
  71.  
  72.  
  73.                 //Send intent to the OS to make
  74.  
  75.                 // it aware that we want to start MySecondActivity as a SubActivity. */
  76.  
  77.                 startActivityForResult(i,MYSECONDACTIVITY_REQUESTCODE);
  78.  
  79.                 }
  80.  
  81.         });
  82.  
  83.                
  84.  
  85.         }
  86.  
  87.     @Override
  88.  
  89.     protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  90.  
  91.         super.onActivityResult(requestCode, resultCode, data);
  92.  
  93.         //* Check which SubActivity returned. * (Here we have only one.) */
  94.  
  95.         switch(requestCode){
  96.  
  97.                 case MYSECONDACTIVITY_REQUESTCODE:
  98.  
  99.                         //* Create a new Intent to * show the Google-Search Page *
  100.  
  101.                         //with the keyword returned. */
  102.  
  103.                         Intent webIntent = new Intent( android.content.Intent.ACTION_VIEW,
  104.  
  105.                                         Uri.parse("http://www.google.com/search?q=" +
  106.  
  107.                                                         data.getExtras().
  108.  
  109.                                                         getString(MainActivity.MY_DEFAULTSTRING_ID)));
  110.  
  111.                 startActivity(webIntent);
  112.  
  113.                         break;
  114.  
  115.         }
  116.  
  117.     }
  118.  
  119. }
  120.  
  121.  
Parsed in 0.039 seconds, using GeSHi 1.0.8.4

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. package org.anddev.andbook.startingsubactivities;
  2.  
  3.  
  4.  
  5. import android.app.Activity;
  6.  
  7. import android.content.Intent;
  8.  
  9. import android.os.Bundle;
  10.  
  11. import android.view.View;
  12.  
  13. import android.view.View.OnClickListener;
  14.  
  15. import android.widget.Button;
  16.  
  17. import android.widget.EditText;
  18.  
  19. import android.util.Log;
  20.  
  21.  
  22.  
  23. public class MySecondActivity extends Activity {
  24.  
  25.         //protected static final String KEYWORD_ID = "keyword1";
  26.  
  27.         public Intent intent;
  28.  
  29.         public EditText et_keyword;
  30.  
  31.         //public String keyword;
  32.  
  33.        
  34.  
  35.             /** Called when the activity is first created. */
  36.  
  37.             @Override
  38.  
  39.             public void onCreate(Bundle savedInstanceState) {
  40.  
  41.                 super.onCreate(savedInstanceState);
  42.  
  43.                 setContentView(R.layout.second);
  44.  
  45.  
  46.  
  47.                 //* Get the EditText from the XML-file. */
  48.  
  49.                 et_keyword = (EditText) findViewById(R.id.et_keyword);
  50.  
  51.                 et_keyword.setText(getIntent().getExtras().getString(MainActivity.MY_DEFAULTSTRING_ID));
  52.  
  53.                                
  54.  
  55.                 //* Get the return-Button from the XML-file. */
  56.  
  57.                 Button b2 = (Button)findViewById(R.id.btn_return);
  58.  
  59.                 //* Make that Button handle clicks to itself. */
  60.  
  61.                 b2.setOnClickListener(new MyOnClickListener());
  62.  
  63.             }
  64.  
  65.            
  66.  
  67. class MyOnClickListener implements OnClickListener {
  68.  
  69.         public void onClick(View arg0) {
  70.  
  71.                 //* Place code to handle Button-Click here. */
  72.  
  73.                 //* Retrieve the Text from the EditText. */
  74.  
  75.                 String keyword = et_keyword.getText().toString();
  76.  
  77.               getIntent().putExtra(MainActivity.MY_DEFAULTSTRING_ID, keyword);
  78.  
  79.                
  80.  
  81.               MySecondActivity.this.setResult(RESULT_OK, getIntent());
  82.  
  83.  
  84.  
  85.                 //* Our Activity is done and shall be closed. */
  86.  
  87.                 MySecondActivity.this.finish();
  88.  
  89.                 }
  90.  
  91.         }
  92.  
  93. }
Parsed in 0.037 seconds, using GeSHi 1.0.8.4
gymshoe
Junior Developer
Junior Developer
 
Posts: 15
Joined: Wed Sep 10, 2008 6:07 am

Postby daisy_deepa » Thu Sep 25, 2008 10:56 am

Really useful book for the Beginner...
Thank You PlusMinus :o
daisy_deepa
Junior Developer
Junior Developer
 
Posts: 19
Joined: Wed Sep 24, 2008 1:55 pm
Location: Chennai

problem with constant

Postby Artur79 » Fri Sep 26, 2008 1:00 pm

Hi, I've just copied a code above and runned it. Until last SDK update everything was fine, but today I had an error:

SDL_app: emulator.exe - Application Error

The instruction at "0x00436070" referenced memory at "0x02c2799c". The memory could not be "written".


When I've removed a line
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. private static final int MYSECONDACTIVITY_REQUESTCODE = 0x1337;
Parsed in 0.034 seconds, using GeSHi 1.0.8.4

emulator runned normally. I've tried to change it to different random values, but always have the same error response.
Someone knows what's going on ?

-------------- Edit --------------
I've uninstalled Android SDK for Eclipse, installed again and clicked on Android Tools > Fix Project Properities and error had been fixed :!: :mrgreen:
But I am still interested what was wrong :?
Artur79
Developer
Developer
 
Posts: 26
Joined: Fri Sep 26, 2008 12:53 pm

Re: problem with constant

Postby plusminus » Sat Sep 27, 2008 5:30 am

Artur79 wrote:Hi, I've just copied a code above and runned it. Until last SDK update everything was fine, but today I had an error:

SDL_app: emulator.exe - Application Error

The instruction at "0x00436070" referenced memory at "0x02c2799c". The memory could not be "written".


When I've removed a line
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. private static final int MYSECONDACTIVITY_REQUESTCODE = 0x1337;
Parsed in 0.034 seconds, using GeSHi 1.0.8.4

emulator runned normally. I've tried to change it to different random values, but always have the same error response.
Someone knows what's going on ?

-------------- Edit --------------
I've uninstalled Android SDK for Eclipse, installed again and clicked on Android Tools > Fix Project Properities and error had been fixed :!: :mrgreen:
But I am still interested what was wrong :?


I strongly assume that something was badly compiled, because of old and therefore incompatible Project Properties.

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby William Wen » Sat Sep 27, 2008 4:17 pm

Book is always better than 'doc'. Really appreciate your great job, plusminus.
William Wen
William Wen
Junior Developer
Junior Developer
 
Posts: 11
Joined: Tue Sep 23, 2008 4:28 pm

Postby shraddha294 » Mon Oct 06, 2008 7:53 am

I very highly appreciate Nicolas's work and his website... anddev... I've learnt a lot from this site..
I just saw this book and in contrast to all the above comments i am not happy with the book. :(

Basically, because most of the material that it contains is from the docs available on code.google.com.
Hardly has anything that's not available in android docs
Plusminus has so much more to share than the contents in documentation.
Apart from the basics, i would love to see more undocumented stuff in his book like common tasks- networking, handling databases etc... there are many things on the anddev that are not explicitly mentioned in android SDK documentation, and that's what makes anddev special.... I wish some of those useful tutorials, imp tasks for development, and +-'s first hand experience on android was included in the book....
shraddha294
Freshman
Freshman
 
Posts: 4
Joined: Tue Sep 16, 2008 10:00 am

Top
PreviousNext

Return to Android Books

Who is online

Users browsing this forum: No registered users and 1 guest