Reputation: 3
I'm using the "Sams teach yourselfh Android Application Develoment in 24 hours" Book.
Got this program
package com.androidbook.droid1;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
/**
* @author Trashcan
*
*/
public class Droid1Activity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
private static final String TAG = "app_name";
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Log.i(TAG,"WTF is going on ?");
}
}
http://developer.android.com/reference/android/util/Log.html is the API of it.
Been trying and dorking around with it and just haven't gotten to any idea where Eclipse will accept it.
Upvotes: 0
Views: 130
Reputation: 10908
you can't define a static
variable within a method. Refactor your code so that the declaration of TAG
is at the class level. For example:
package com.androidbook.droid1;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
/**
* @author Trashcan
*
*/
public class Droid1Activity extends Activity {
private static final String TAG = "app_name";
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Log.i(TAG,"WTF is going on ?");
}
}
Upvotes: 0
Reputation: 5739
Try calling super.onCreate(savedInstanceState)
first in onCreate()
. I'm not sure if this will fix anything, but I can't really tell what your problem is.
Also, it would seem more appropriate to use Log.wtf()
in this particular case, but that's my personal opinion.
Upvotes: 0
Reputation: 11909
There is a line there that shouldn't be in the method but outside of the method. Don't you get a warning saying as much?
Upvotes: 3