Android Build a Simple Android App with Java Testing and Debugging Writing to the Log

prosper nyamukondiwa
prosper nyamukondiwa
656 Points

help please is this the answer

Inside the onCreate() method (after the setContentView() call), log the message "Activity created!" using the Log debug method (remember it's just one letter). The 1st parameter should be "TreehouseActivity", but use the TAG variable instead of typing it out a second time. The 2nd parameter is the message.

com/teamtreehouse/TreehouseActivity.java
package com.teamtreehouse;

public class TreehouseActivity extends Activity {

  public static final String TAG = "TreehouseActivity";

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_treehouse);

    Log.d(tag:"Activitycreated"; msg :"TreehouseActivity!; 

  }
}

1 Answer

Zach Freitag
Zach Freitag
18,862 Points

There are a few issues with your log statement:

  1. "tag" should be "TAG"
  2. Remove the colon after "tag" - You must use a comma.
  3. Delete "Activitycreated" - I'm not sure how you came up with that, it has no business here.
  4. Delete "msg" - "msg" is just a nice UI feature within Android Studio, it does not compile with the code.
  5. Delete the colon after "msg" - We only use commas between the Log Method parentheses.
  6. Delete "TreehouseActivity!
  7. The challenge asks us not to repeat the value of the "TAG" variable listed above which is "TreehouseActivity"
  8. After TAG, you are asked to display the message they have listed.

Reading through these 8 key points you are left with this skeleton:

Log.d(TAG, "_______");

What message does the challenge ask you to display?

Zach Freitag
Zach Freitag
18,862 Points

I would love if you selected my response for best answer!

Cheers!