Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android

Not able to find error in code

code challenge, no one got back to me on this so I trying the blog here .

Hi Chris We got your help request and it's been assigned to the right person on our Team.

Thanks! Team Treehouse From: Chris Lundberg chrisrlundberg@gmail.com Date: June 21, 2013 4:23:53 AM EDT To: Treehouse Support help@teamtreehouse.com Subject: cant find error in my code Android chalenge 3 of 3

package com.example;

import android.os.Bundle;
import android.view.View;
import java.io.IOException;
import java.net.MalformedURLException;
import android.util.Log;
import android.os.AsyncTask;


public class MainListActivity extends ListActivity {

public static final String URL = "http://www.teamtreehouse.com";
public static final String TAG = MainListActivity.class.getSimpleName();

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_list);
CustomAsyncTask.execute();
}
private class CustomAsyncTask extends AsyncTask {
@Override
protected String doInBackground(Object... params) {

try {
URL treehouseUrl = new URL(URL);
HttpURLConnection connection = (HttpURLConnection) treehouseUrl.openConnection();
connection.connect();
int responseCode = connection.getResponseCode();
}
catch (MalformedURLException e) {
Log.e(TAG, "MalformedURLException caught!", e);
}
catch (IOException e) {
Log.e(TAG, "IOException caught!", e);
}
return "";
}
}
}

Personally I would have given them a little longer than a day.

I guess they spoil us, and it was two days . I'am not twisting arms just would like to move ahead in my training .

Chris Lundberg -

I'm not twisting arms just would like to move ahead in my training .

A lot of people when they post on this forum use similar language about "moving ahead" as if debugging your code isn't part of programming. Out in the real world, you'll spend twice as much time on average debugging code as you will writting it.

Chris Lundberg - Help us help you

As far questions go, your post is missing some important information for some tips on how to improve it, [check out some tips on how to ask good questions on the forum

In the real world programmers use debuggers to check for syntax errors and other code problems, Also in the real world after hours of time trying to figure out a possible typo a person my ask for help like they do on stack overflow forums . Code challenge without a debugging tools is not real world I'm just trying to make the best of what we got here . This is getting out of hand I just ask for help on a code challenge only . This is day three now and I feel abused ,

Chris Lundberg - I'm sorry you've had so much trouble.

Can you provide me a to the code challenge you are having issues with? Have you tried, throwing your your code in Eclipse and turning on debugging by any chance?

1 Answer

package com.example;

import android.os.Bundle;

import android.view.View;

import java.io.IOException;

import java.net.MalformedURLException;

import android.util.Log;

import android.os.AsyncTask;

public class MainListActivity extends ListActivity {

public static final String URL = "http://www.teamtreehouse.com";

public static final String TAG = MainListActivity.class.getSimpleName();



@Override

public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_main_list);

    CustomAsyncTask.execute();

}

private class CustomAsyncTask extends AsyncTask {

@Override

                            protected String doInBackground(Object... params) {



try {

        URL treehouseUrl = new URL(URL);

        HttpURLConnection connection = (HttpURLConnection) treehouseUrl.openConnection();

        connection.connect();

       int responseCode = connection.getResponseCode();

    }

    catch (MalformedURLException e) {

        Log.e(TAG, "MalformedURLException caught!", e);

    }

    catch (IOException e) {

        Log.e(TAG, "IOException caught!", e);

    }

  return "";

}

}

}

This code was step three in code challenge . I didn't put the code in eclipse yet will create a activity so I could paste it into and try it out. The title is missing if you need it let me know .

Thank you

Found error, I didn't initialize variable before using execute command .

Ben Jakuben
Ben Jakuben
Treehouse Teacher

Hi Chris Lundberg,

Sorry about the delayed response! That's my fault. The ticket was assigned to me but we are off Thu-Sun. I try to hop in the forum and check support on the weekends but some weekends are busier than others. :) Fortunately our other students and moderators are quite active during the weekend!

Glad you got it solved and could move on. Also, know that your feedback about having more helpful information in the code challenges for errors is not falling on deaf ears. It's something we're aware of and hope to improve.

No problem, I finish the Blog app now I'm just messing with it to make it do other things I hope I don't break it beyond repair .

Thanks for getting back to me and don't worry about your schedule I will work around it.

Chris