Android : HttpClient POST : NullPointerException?

There could be too many reasons for that, and if you don't tell us which line is the number 60 we are not going to be able to help you. Anyway... so far I see a clear NullpointerException case: you first call login() and after that you initialize txtResult login(); layout = new LinearLayout(this); txtResult = new TextView(this) That of course will cause a NullPointerException because inside login() you are doing: txtResult. SetText(HttpHelper.

Request(response)) In that case txtResult have not been initialized, thus it's null Edit: Sigh... doing TextView txtResult = new TextView(this) outside any method will cause another NullPointerException That's because the use of this You better read little bit more about what it means, but let me give you a simple explanation: this is a keyword used to reference an instance of the object current object. Every initialization you do that is not inside a method will be called before the constructor is invoked (that's called lazy initialization), thus in that case the object has not been instantiated and this will be null What you have to do, and I thought you were going to get the idea is: layout = new LinearLayout(this); txtResult = new TextView(this); login().

There could be too many reasons for that, and if you don't tell us which line is the number 60 we are not going to be able to help you. Anyway... so far I see a clear NullpointerException case: you first call login() and after that you initialize txtResult login(); layout = new LinearLayout(this); txtResult = new TextView(this); That of course will cause a NullPointerException because inside login() you are doing: txtResult. SetText(HttpHelper.

Request(response)); In that case, txtResult have not been initialized, thus it's null. Edit: Sigh... doing TextView txtResult = new TextView(this); outside any method will cause another NullPointerException. That's because the use of this.

You better read little bit more about what it means, but let me give you a simple explanation: this is a keyword used to reference an instance of the object current object. Every initialization you do that is not inside a method will be called before the constructor is invoked (that's called lazy initialization), thus in that case the object has not been instantiated and this will be null. What you have to do, and I thought you were going to get the idea is: layout = new LinearLayout(this); txtResult = new TextView(this); login().

I made an update – user427807 Aug 22 '10 at 21:05 I also updated my answer. – Cristian Aug 22 '10 at 21:44 wow I feel like an idiot. Haha, thanks Cristian let me update.

– user427807 Aug 23 '10 at 15:14.

I am new to Android development since my EVO purchase a few months ago. Anyway, I am developing my first Android app using Eclipse and Android SDK emulator. I am trying to do a simple HTTP POST.

My real code has my login information hard coded in so I replaced it with test information and I changed the url as well to simply POST to google.com. I am getting a NullPointerException when trying to view the HTTP POST request response. I have added the internet permissions to my manifest xml file as well.

Here is my code. I have initialized the txtResult TextView object and I am getting new NullPointerException.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions