jYMSG on Android - Help please

by Mallikharjuna Reddy Deva » Fri, 06 Feb 2009 18:26:29 GMT


Sponsored Links
 Hi,

 My name is Mallikharjuna.I am trying to implement Yahoo Instant
Messengerin Android platform. I have downloaded jYMSG JAR
file and used that jar file with my sample application in Android.

I have followed the following procedure for login

---------------------------------
* private* *void* login() {

   yahooMessengerSession = *new* Session();

   mySessionListener = *new* MySessionListener(*this*);

   yahooMessengerSession.addSessionListener(mySessionListener);

   String usrName = userName.getText().toString();

   String pword = password.getText().toString();

*   try*

   {

*       if*(usrName.equals(*null*) || pword.equals(*null*)){

            Log.*e*("YahooClient", "User name or password empty");

       } *else* {

            Log.*i*("YahooClient", "Trying to login");

            yahooMessengerSession.login(usrName, pword);

       }
} *catch* (IOException e1) {

   Log.*e*("YahooClient", "login: IOException");

   e1.printStackTrace();
}
}
---------------------------------

But I am getting following exception,

-------------------------------
java.net.UnknownHostException: scs.msg.yahoo.com - scs.msg.yahoo.com
-------------------------------

with following stack trace:

--------------------------------------
java.net < http://java.net.in/> ;
.InetAddress.lookupHostByName(InetAddress.java:457)
java.net < http://java.net.inetaddress.ge/> ;
.InetAddress.getByName(InetAddress.java:287)
java.net < http://java.net.so/> ;.Socket.<init> (Socket.java:140)
org.openymsg.network.DirectConnectionHandler.open(DirectConnectionHandler.java:95)
org.openymsg.network.Session.openSession(Session.java:2865)
org.openymsg.network.Session.login(Session.java:292)
--------------------------------------

If use this library in simple Java application in PC, I could successfully
login and send messages to other yahoo accounts.
I could successfully ping scs.msg.yahoo.com

The above two shows that there there is no problem with either yahoo server
or jYMSG library.
It is having problems in using in Android, I guess.

I am absolutely struck with this and I could not make any progress from
here. Could you please help out in solving this problem?

I greatly appreciate your help.

Thanks

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



jYMSG on Android - Help please

by for android » Fri, 06 Feb 2009 19:04:45 GMT


 have u specfied the Internet permission in your manifest file..

On Fri, Feb 6, 2009 at 3:56 PM, Mallikharjuna Reddy Deva <




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


Sponsored Links


jYMSG on Android - Help please

by Maddy » Fri, 06 Feb 2009 19:32:25 GMT


 Hi,

Thanks for your response. No I have not done anything for giving
permissions in manifest file.

Could you please let me know how we would do that?

Thank you very much in avance for your help.

On Feb 6, 10:26am, Mallikharjuna Reddy Deva <malli.ar...@gmail.com>


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



jYMSG on Android - Help please

by Maddy » Fri, 06 Feb 2009 20:47:54 GMT


 i,

I have managed to give internet permission in my manifest file (thanks
for the point)
and looks like now it could find the host but I am getting the
following error,

-----------------
Error loading resource file: challenge.bin
java.lang.NullPointerException
at java.io.FilterInputStream.available(FilterInputStream.java:63)
at ymsg.network.ChallengeResponseV10.<clinit>
(ChallengeResponseV10.java:71)
at ymsg.network.Session.receiveAuth(Session.java:1109)
at ymsg.network.Session$InputThread.process(Session.java:2314)
at ymsg.netwrok.Session$InputThread.run(Session.java:2285)
Input Exception Thrown.
------------------------

But I have put the challenge.bin at the right place for picking up (it
is part of jYMSG library).
Then to try I have placed the chanllenge.bin in res/raw folder of my
android project, even then it could not pick this resource file.

I think I am very close to get successfully login but the above
problem should be solved though.

Please help me or give some clue on how to solve this problem.

Thanks


On Feb 6, 11:32am, Maddy <malli.ar...@gmail.com> wrote:
--~--~---------~--~----~------------~-------~--~----~



jYMSG on Android - Help please

by Mark Murphy » Fri, 06 Feb 2009 21:06:36 GMT


 


What do you think "the right place for picking up" is? I cannot find
anything on challenge.bin with respect to jYMSG, though I have not spent
much time searching.

Please bear in mind that there are very few places for Android
applications to put files, and that these places are unlikely to be the
default spots expected by existing JavaSE JARs.


If jYMSG has not been ported to Android, it would have no knowledge of
the APIs necessary to work with res/raw/ resources.


If jYMSG is to remain platform-independent, most likely you will need to
pass an InputStream into jYMSG, opened on challenge.bin in a spot where
you can store it (e.g., raw resource). That way, jYMSG does not need to
know or care where the challenge.bin file is actually stored.

If jYMSG does not support this, you may need to work with the jYMSG team
to add this support to their library.

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com 
_The Busy Coder's Guide to Android Development_ Version 2.0 Published!

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



jYMSG on Android - Help please

by Maddy » Fri, 06 Feb 2009 22:23:37 GMT


 i Murphy,

jYMSG has got the following structure

ymsg
|
--network
some java files (both ChallengeResponseV10.java and challenger.bin
are placed at this level)
|
--event
some java files

In ChallengeResponseV10.java file he is doing the following to load
challenge.bin file,

.......
.......
// -----Buffer for binary data, and resource filename
private static byte[] data;
private final static String BIN_FILE="challenge.bin";


// -----------------------------------------------------------------
// 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");
DataInputStream dis = new
DataInputStream(v10.getResourceAsStream
(BIN_FILE));
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:
"+BIN_FILE);
e.printStackTrace();
}
}

I don't understand why getResourceAsStream() failed to load the file
which is being present at the same directory level!

Then I tried removing challenge.bin in this location and moved to res/
raw folder of my Android project, even then no luck!

Please let me know if I have to change something to above code
correctly pick the file.

Thanks

On Feb 6, 1:06pm, Mark Murphy <mmur...@commonsware.com> wrote:
--~--~---------~--~----~------------~-------~--~----~



jYMSG on Android - Help please

by Mark Murphy » Fri, 06 Feb 2009 22:27:39 GMT


 


I don't believe getResourceAsStream() necessarily works on Android.


If you didn't change the code in the snippet you quoted, you will not
have any luck.


Try replacing:

v10.getResourceAsStream(BIN_FILE)

with:

resources.openRawResource(R.raw.challenge)

where:

-- resources is a Resources object, typically obtained via calling
getResources() on an Activity, Service, or other Context

-- you have put challenge.bin in res/raw/

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com 
_The Busy Coder's Guide to Android Development_ Version 2.0 Available!

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



jYMSG on Android - Help please

by Maddy » Fri, 06 Feb 2009 22:44:07 GMT


 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.

How can we get resources from non-Android code, I mean from
ChallengeResponseV10.java which is a simple Java file?

Sorry if I am asking a very basic question?

Thanks





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



jYMSG on Android - Help please

by Mark Murphy » Fri, 06 Feb 2009 23:11:23 GMT


 


Activity inherits from Context. Service inherits from Context.


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!

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



jYMSG on Android - Help please

by Maddy » Sat, 07 Feb 2009 00:00:30 GMT


 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.





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



jYMSG on Android - Help please

by Maddy » Sat, 07 Feb 2009 02:19:49 GMT


 Hi All,

I am trying to implement Yahoo Instant Messenger in Android platform.
I have downloaded jYMSG JAR file and
used that jar file with my sample application in Android.

I have followed the following procedure for login

---------------------------------
private
void login() {
  yahooMessengerSession = new Session();
  mySessionListener = new MySessionListener(this);
  yahooMessengerSession.addSessionListener(mySessionListener);
  String usrName = userName.getText().toString();
  String pword = password.getText().toString();
  try
  {
      if(usrName.equals(null) || pword.equals(null)){
           Log.e("YahooClient", "User name or password empty");
     } else {
           Log.i("YahooClient", "Trying to login");
           yahooMessengerSession.login(usrName, pword);
      }
   } catch(IOException e1) {
           Log.e("YahooClient", "login: IOException");
           e1.printStackTrace();
   }
}
---------------------------------

But I am getting following exception,

-------------------------------
java.net.UnknownHostException: scs.msg.yahoo.com - scs.msg.yahoo.com
-------------------------------

with following stack trace:

--------------------------------------
java.net.InetAddress.lookupHostByName(InetAddress.java:457)
java.net.InetAddress.getByName(InetAddress.java:287)
java.net.Socket.<init> (Socket.java:140)
org.openymsg.network.DirectConnectionHandler.open
(DirectConnectionHandler.java:95)
org.openymsg.network.Session.openSession(Session.java:2865)
org.openymsg.network.Session.login(Session.java:292)
--------------------------------------

If use this library in simple Java application in PC, I could
successfully login and send messages to other yahoo accounts.
I could successfully ping scs.msg.yahoo.com

The above two shows that there there is no problem with either yahoo
server or jYMSG library.
It is having problems in using in Android, I guess.

I am absolutely struck with this and I could not make any progress
from here. Could you please help out in solving this problem?

I greatly appreciate your help.

Thanks

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



jYMSG on Android - Help please

by Android_Beginner » Sat, 07 Feb 2009 02:22:21 GMT


 Hi All,

My name is Mallikharjuna.I am trying to implement Yahoo Instant
Messenger in Android platform. I have downloaded jYMSG JAR file and
used that jar file with my sample application in Android.

I have followed the following procedure for login

---------------------------------
private
void login() {
   yahooMessengerSession = new Session();
   mySessionListener = new MySessionListener(this);
   yahooMessengerSession.addSessionListener(mySessionListener);
   String usrName = userName.getText().toString();
   String pword = password.getText().toString();
   try
   {
       if(usrName.equals(null) || pword.equals(null)){
            Log.e("YahooClient", "User name or password empty");
      } else {
            Log.i("YahooClient", "Trying to login");
            yahooMessengerSession.login(usrName, pword);
       }
    } catch(IOException e1) {
            Log.e("YahooClient", "login: IOException");
            e1.printStackTrace();
    }
}
---------------------------------

But I am getting following exception,

-------------------------------
java.net.UnknownHostException: scs.msg.yahoo.com - scs.msg.yahoo.com
-------------------------------

with following stack trace:

--------------------------------------
java.net.InetAddress.lookupHostByName(InetAddress.java:457)
java.net.InetAddress.getByName(InetAddress.java:287)
java.net.Socket.<init> (Socket.java:140)
org.openymsg.network.DirectConnectionHandler.open
(DirectConnectionHandler.java:95)
org.openymsg.network.Session.openSession(Session.java:2865)
org.openymsg.network.Session.login(Session.java:292)
--------------------------------------

If use this library in simple Java application in PC, I could
successfully login and send messages to other yahoo accounts.
I could successfully ping scs.msg.yahoo.com

The above two shows that there there is no problem with either yahoo
server or jYMSG library.
It is having problems in using in Android, I guess.

I am absolutely struck with this and I could not make any progress
from here. Could you please help out in solving this problem?

I greatly appreciate your help.

Thanks

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



jYMSG on Android - Help please

by Al » Sat, 07 Feb 2009 06:39:10 GMT


 Did you declare a permission to access the Internet in the manifest?
The android system doesn't throw any 'bad permissions' exception with
sockets as it would with something like wifi locking.



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



jYMSG on Android - Help please

by Maddy » Mon, 09 Feb 2009 22:53:10 GMT


 i 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:00pm, Maddy <malli.ar...@gmail.com> wrote:
--~--~---------~--~----~------------~-------~--~----~



jYMSG on Android - Help please

by Mark Murphy » Mon, 09 Feb 2009 22:58:24 GMT


 


What is the exception?

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com 
Android Training in Sweden --  http://www.sotrium.com/training.php 

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



Other Threads

1. Error using graphics in XML-Based UI



Do not use plus in android:src. It should be:

android:src="@drawable/eclipse"

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com

Android Training on the Ranch! -- Mar 16-20, 2009
http://www.bignerdranch.com/schedule.shtml

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

2. Requests: doc/FAQ fix & addition to SDK samples



The easier solution is to run activitycreator, passing it the name of a
class that already exists:

activitycreator com.sample.this.class.is.in.the.app.Already

The activitycreator script will then just create the missing build.xml
file for you.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com

Android Training on the Ranch! -- Mar 16-20, 2009
http://www.bignerdranch.com/schedule.shtml

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

3. Google phone dev 1 keyboard issues

4. Gmail app on Android, how to change view?

5. Here comes skype.....

6. No reply on market

7. Is there a SeekBar preference?