Hi Murphy,
I have just used Looper.prepare() before creating my YahooClient
object as shown below,
.........
.........
Looper.prepare();
YahooClient yahooClient = new YahooClient();
InputStream istream = yahooClient.retInputStream();
........
........
I am getting the following error as seen in Logcat
-----------------
java.lang.NullPointerException
at android.content.ContextWrapper.getResources(ContextWrapper.java:
79)
at AndJYMSG.YahooClient.retInputStream(YahooClient.java:102)
at ymsg.network.ChallengeResponseV10.<clinit>
(ChallengeResponseV10.java:77)
-----------------
--------------
// The source code of YahooClient.retInputStream() is as follows
public InputStream retInputStream(){
Resources resource;
resource = this.getResources();
istream = resource.openRawResource(R.raw.challenge);
return (istream);
}
-------------
>From the error message I could see that *this* pointer is not
correctly initialized (it is NULL).
Is using of Looper.prepare() correct? If not please let me know how
could I use it properly.
As I said before I am very new to Android and please excuse me if I am
asking some basic questions.
I must say count less thanks for your help.
Thanks
Maddy
On Feb 9, 5:06 pm, Mark Murphy <[email protected]> wrote:
> Maddy wrote:
> > I am getting following error as seen in Logcat
>
> > --------------------------------------
> > java.lang.RuntimeException: Can't create handler inside thread that
> > has not called Looper:prepare()
> > at android.os.Handler.<init>(Handler.java:111)
> > at android.app.Activity.<init>(Activity.java:660)
> > at AndJYMSG.YahooClient.<init>(YahooClient.java:20)
> > at ymsg.network.ChallengeResponseV10.<clinit>
> > (ChallengeResponseV10.java:73)
> > at ymsg.network.Session.receiveAuth(Session.java:1114)
> > at ymsg.network.Session$InputThread.process(Session.java:2322)
> > at ymsg.network.Session$InputThread.run(Session.java:2293)
>
> You appear to be trying to use a Handler from a thread other than the
> main UI thread. While the error message suggests you need to call
> Looper:prepare(), and while that may be an answer, it is also possible
> you need to find some other form of inter-thread communication.
>
> --
> Mark Murphy (a Commons Guy)http://commonsware.com
> _The Busy Coder's Guide to Android Development_ Version 2.0 Available!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Android Discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---