I think I am having a problem with the Log.d(TAG,name) When I run the project it says "Unfortunately Stopped"
Intent intent = getIntent(); String name = intent.getStringExtra("name"); Log.d(TAG,name);
Steve HunterTreehouse Moderator 57,656 Points
Your code looks fine as long as two things have been added - these are in the video.
You start in the
MainActivity where you add a string value to the intent using
putExtra and the key called
name. You're then using the key to get the data out of the intent in
StoryActivity. So, you need to have used the key
"name" for this to work - the key must be identical in both activities.
Second, you need to have added the constant called
TAG to the top of your class. That way the
Log.d knows what
TAG is. This line is added at 2:07 in the video.
I hope that helps. If not, in the Android Log, where you're expecting your message to appear, you should get an error message which explains why your app "unfortunately stopped". Post those error messages in here. They'll tell us why your app crashed.
Marc Reid7,830 Points
Newer versions of Android Studio seem to prefer you to use...
import static android.util.Log.d;
for some reason following the video exactly produces an error.