Hi Murphy,
Sorry, actually I still could not open the challenge.bin file for
successfully loging to Yahoo IM using jYMSG library.
I am putting the code snippet that I am using to open the InputStream,
----------------
// This is my sample application activity for my Yahoo IM Client in
Android
public class YahooClient extends Activity {
.....
.....
static InputStream istream;
.....
.....
public InputStream retInputStream(){
Resources resource;
resource = this.getResources();
istream = resource.openRawResource(R.raw.challenge);
return (istream);
}
....
....
-------------------------------
Part of ChallengeResponseV10.java code where challenge.bin is read
class ChallengeResponseV10 extends ChallengeResponseUtility
implements ChallengeResponseV10Tables
{
......
......
// -----Buffer for binary data, and resource filename
private static byte[] data;
private final static String BIN_FILE="challenge.bin";
private static YahooClient yahooClient;
// -----------------------------------------------------------------
// Load binary data tables as a resource from /ysmg/network/BIN_FILE
// -----------------------------------------------------------------
static
{ try
{ // -----Open stream to resource located next to this class
Class v10 = Class.forName("ymsg.network.ChallengeResponseV10");
InputStream istream = yahooClient.retInputStream();
//DataInputStream dis = new
DataInputStream(v10.getResourceAsStream
(BIN_FILE));
DataInputStream dis = new DataInputStream(istream);
System.out.println("ChallengeResponseV10: available bytes
value:");
System.out.print(dis.available());
data = new byte[dis.available()];
// -----Extra entry at end of offset table has entire file size
if(data.length<TABLE_OFFSETS[TABLE_OFFSETS.length-1])
throw new Exception("Data too short?");
// -----Read binary data into array
dis.readFully(data);
dis.close();
}
catch(Exception e)
{ System.err.println("Error loading resource file: ");
e.printStackTrace();
}
}
-------------------------------------
I always get the exception and could not open the InputStream for
chanllenge.bin, which is must for jYMSG library to work properly.
So could you please help me out in identifying where I am making the
mistake in the above code.
I appreciate your response.
Thanks
On Feb 6, 4:00 pm, Maddy <[email protected]> wrote:
> Hi Murphy,
>
> Thanks for your response.
>
> I have now managed open the challenge.bin file.
>
> But still I could not successfully login, this time I get different
> error,
>
> the following thing is seen in Logcat
>
> ------------------------
> Tag Message
> ----- -----------------
> System.out Input Exception Thrown
> Sytem.err java.io.InterruptedIOException: Login timed
> out
> dalvikvm threadid=19 wakeup:interrupted
> System.err at ymsg.network.Session.login(Session.java:136)
>
> ----------------------------------------
>
> Any idea to get rid of this error?
>
> Thanks for your great help.
>
> On Feb 6, 3:11 pm, Mark Murphy <[email protected]> wrote:
>
>
>
> > Maddy wrote:
> > > Hi Murphy,
>
> > > I understand what you are saying and I know how to get 'resources'
> > > object from an Activity/Service.
> > > But I do not know how do we get in other context you said.
>
> > Activity inherits from Context. Service inherits from Context.
>
> > > How can we get resources from non-Android code, I mean from
> > > ChallengeResponseV10.java which is a simple Java file?
>
> > As far as I know, you don't.
>
> > --
> > Mark Murphy (a Commons Guy)http://commonsware.com
> > _The Busy Coder's Guide to Android Development_ Version 2.0 Available!-
> > Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---