Problems with HttpClient, HttpGet and HttpResponse ...

by rustyventure » Tue, 09 Dec 2008 10:22:39 GMT


Sponsored Links
 Hi, everyone:

I'm just starting to play around with the Android SDK, but i haven't
developed any Java apps for a few years and my skills are a little
rusty ...

I'm trying some code that uses the HttpClient class. From what I've
seen from other online examples, the following code should work:

HttpClient httpclient = new DefaultHttpClient();
HttpGet httpget = new HttpGet(" http://www.google.com ");
HttpResponse response = httpclient.execute(httpget);

However, Eclipse won't let me debug this as httpclient.execute
(httpget) is underlined with an error: "Unhandled exception type
ClientProtocolException". Any ideas why I'm getting this error? Thanks
in advance!

--~--~---------~--~----~------------~-------~--~----~



Problems with HttpClient, HttpGet and HttpResponse ...

by rustyventure » Wed, 10 Dec 2008 03:49:14 GMT


 Looks like I answered my own question :)

I allowed Eclipse to auto correct my code, and it added a try - catch
routine:

HttpClient httpclient = new DefaultHttpClient();
        HttpGet httpget = new HttpGet(" http://www.google.com ");
        try {
                        HttpResponse response = httpclient.execute(httpget);
                } catch (ClientProtocolException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }

My code complies now, so I can go back to exploring :)





--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Other Threads

1. Fwd: ADC 2

My guess is open source apps hosted in googlecode etc., should be fine if
you don't publish "apk" for download. Hope the final rules sheds enough
light on this open source projects being excluded from ADC2 is correct or
not.

take care,
Muthu Ramadoss.

http://linkedin.com/in/tellibitz
http://androidrocks.googlecode.com - Android Consulting.


Helen Rowland<http://www.brainyquote.com/quotes/authors/h/helen_rowland.html>
- "One man's folly is another man's wife."

















--~--~---------~--~----~------------~-------~--~----~

2. The app got crashed on SDK 1.5 which is working fine on SDK 1.0

Hi friends,

I have developed an application which has tabActivity using SDK 1.0
r2.

1st Tab contains List view. -> the list contains some images

2nd and 3rd contains some webviews.

The app works fine on G1 mobile.

Today I downloaded SDK 1.5 and ran the same app on SDK 1.5.

The app got crashed when I scroll down/up the list items very fast
(fling)

I/dalvikvm( 1006): Stack overflow, expanding (0x41048200 to
0x41048000)
I/dalvikvm( 1006): Shrank stack (to 0x41048200, curFrame is
0x41049cd8)
D/AndroidRuntime( 1006): Shutting down VM
W/dalvikvm( 1006): threadid=3: thread exiting with uncaught exception
(group=0x4000fe70)
E/AndroidRuntime( 1006): Uncaught handler: thread main exiting due to
uncaught exception
E/AndroidRuntime( 1006): java.lang.StackOverflowError
E/AndroidRuntime( 1006):        at android.text.Styled.measureText
(Styled.java:371)
E/AndroidRuntime( 1006):        at android.text.Layout.measureText
(Layout.java:1600)
E/AndroidRuntime( 1006):        at android.text.Layout.getLineMax
(Layout.java:654)
E/AndroidRuntime( 1006):        at android.text.Layout.draw(Layout.java:310)
E/AndroidRuntime( 1006):        at android.text.BoringLayout.draw
(BoringLayout.java:356)
E/AndroidRuntime( 1006):        at android.widget.TextView.onDraw
(TextView.java:3921)
E/AndroidRuntime( 1006):        at android.view.View.draw(View.java:5838)
E/AndroidRuntime( 1006):        at android.view.ViewGroup.drawChild
(ViewGroup.java:1486)
E/AndroidRuntime( 1006):        at android.view.ViewGroup.dispatchDraw
(ViewGroup.java:1228)
E/AndroidRuntime( 1006):        at android.view.View.buildDrawingCache
(View.java:5615)
E/AndroidRuntime( 1006):        at android.view.View.getDrawingCache
(View.java:5458)
E/AndroidRuntime( 1006):        at android.view.ViewGroup.drawChild
(ViewGroup.java:1422)
E/AndroidRuntime( 1006):        at android.view.ViewGroup.dispatchDraw
(ViewGroup.java:1228)
E/AndroidRuntime( 1006):        at android.widget.AbsListView.dispatchDraw
(AbsListView.java:1319)
E/AndroidRuntime( 1006):        at android.widget.ListView.dispatchDraw
(ListView.java:2820)
E/AndroidRuntime( 1006):        at android.view.View.draw(View.java:5944)
E/AndroidRuntime( 1006):        at android.widget.AbsListView.draw
(AbsListView.java:2121)
E/AndroidRuntime( 1006):        at android.view.ViewGroup.drawChild
(ViewGroup.java:1486)
E/AndroidRuntime( 1006):        at android.view.ViewGroup.dispatchDraw
(ViewGroup.java:1228)
E/AndroidRuntime( 1006):        at android.view.ViewGroup.drawChild
(ViewGroup.java:1484)
E/AndroidRuntime( 1006):        at android.view.ViewGroup.dispatchDraw
(ViewGroup.java:1228)
E/AndroidRuntime( 1006):        at android.view.View.draw(View.java:5944)
E/AndroidRuntime( 1006):        at android.widget.FrameLayout.draw
(FrameLayout.java:352)
E/AndroidRuntime( 1006):        at android.view.ViewGroup.drawChild
(ViewGroup.java:1486)
E/AndroidRuntime( 1006):        at android.view.ViewGroup.dispatchDraw
(ViewGroup.java:1228)
E/AndroidRuntime( 1006):        at android.view.ViewGroup.drawChild
(ViewGroup.java:1484)
E/AndroidRuntime( 1006):        at android.view.ViewGroup.dispatchDraw
(ViewGroup.java:1228)
E/AndroidRuntime( 1006):        at android.view.View.draw(View.java:5841)
E/AndroidRuntime( 1006):        at android.widget.FrameLayout.draw
(FrameLayout.java:352)
E/AndroidRuntime( 1006):        at android.view.ViewGroup.drawChild
(ViewGroup.java:1486)
E/AndroidRuntime( 1006):        at android.view.ViewGroup.dispatchDraw
(ViewGroup.java:1228)
E/AndroidRuntime( 1006):        at android.view.ViewGroup.drawChild
(ViewGroup.java:1484)
E/AndroidRuntime( 1006):        at android.view.ViewGroup.dispatchDraw
(ViewGroup.java:1228)
E/AndroidRuntime( 1006):        at android.view.ViewGroup.drawChild
(ViewGroup.java:1484)
E/AndroidRuntime( 1006):        at android.view.ViewGroup.dispatchDraw
(ViewGroup.java:1228)
E/AndroidRuntime( 1006):        at android.view.ViewGroup.drawChild
(ViewGroup.java:1484)
E/AndroidRuntime( 1006):        at android.view.ViewGroup.dispatchDraw
(ViewGroup.java:1228)
E/AndroidRuntime( 1006):        at android.view.ViewGroup.drawChild
(ViewGroup.java:1484)
E/AndroidRuntime( 1006):        at android.view.ViewGroup.dispatchDraw
(ViewGroup.java:1228)
E/AndroidRuntime( 1006):        at android.view.View.draw(View.java:5841)
E/AndroidRuntime( 1006):        at android.widget.FrameLayout.draw
(FrameLayout.java:352)
E/AndroidRuntime( 1006):        at android.view.ViewGroup.drawChild
(ViewGroup.java:1486)
E/AndroidRuntime( 1006):        at android.view.ViewGroup.dispatchDraw
(ViewGroup.java:1228)
E/AndroidRuntime( 1006):        at android.view.ViewGroup.drawChild
(ViewGroup.java:1484)
E/AndroidRuntime( 1006):        at android.view.ViewGroup.dispatchDraw
(ViewGroup.java:1228)
E/AndroidRuntime( 1006):        at android.view.View.draw(View.java:5841)
E/AndroidRuntime( 1006):        at android.widget.FrameLayout.draw
(FrameLayout.java:352)
E/AndroidRuntime( 1006):        at
com.android.internal.policy.impl.PhoneWindow$DecorView.draw
(PhoneWindow.java:1847)
E/AndroidRuntime( 1006):        at android.view.ViewRoot.draw(ViewRoot.java:
1217)
E/AndroidRuntime( 1006):        at android.view.ViewRoot.performTraversals
(ViewRoot.java:1030)
E/AndroidRuntime( 1006):        at android.view.ViewRoot.handleMessage
(ViewRoot.java:1482)
E/AndroidRuntime( 1006):        at android.os.Handler.dispatchMessage
(Handler.java:99)
E/AndroidRuntime( 1006):        at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 1006):        at android.app.ActivityThread.main
(ActivityThread.java:3948)
E/AndroidRuntime( 1006):        at java.lang.reflect.Method.invokeNative
(Native Method)
E/AndroidRuntime( 1006):        at java.lang.reflect.Method.invoke
(Method.java:521)
E/AndroidRuntime( 1006):        at com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:782)
E/AndroidRuntime( 1006):        at com.android.internal.os.ZygoteInit.main
(ZygoteInit.java:540)
E/AndroidRuntime( 1006):        at dalvik.system.NativeStart.main(Native
Method)

I am not understanding the above error log.

Then I experimented some thing like this: I removed the TabActivity,
just shown only list activity. Then I scroll down/up the list items.
Then there is no crash.

Can any one please help me.

Thanks,
manoj.
--~--~---------~--~----~------------~-------~--~----~

3. installing android os

4. Problem with Internet connection through emulator

5. view Log on device

6. vertical scrolling TableLayout

7. Problem with Internet connection through emulator