java me - sending image from one mobile to another via sms using j2me language -


I am programming a mobile application in j2me, where I need to send an image from one mobile to another via SMS . Problems are being encountered on receipt.This image is not being decoded properly.It is throwing the iPod. I am posting code here..PLG help me

Import javax.microedition.midlet. *; Import javax.microedition.lcdui *; Import javax.microedition.io *; Import javax.wireless.messaging *; Import java.io.IOException; Import javax.microedition.lcdui.game. *; Import java.lang *; Import java.io * *; Public class receive_mms MIDlet tool commandstore displays {display; // text box Txtbox; Message Connection msgConn; Message message; Form frm = null; Byte [] msgrev; Byte [] data; // string msgrev; Image im = null; Image im1 = null; Image item img = null; Int i, j; Bytereinputstream bracket = null; Command cmd_exit; Public receive_ms () {disp = Display.getDisplay (this); Frm = new form ("see photo"); I = frm.getWidth (); J = frm.getHeight (); Cmd_exit = New command ("Exit", Command.exit, 1); Frm.addCommand (cmd_exit); Frm.setCommandListener (this); Disp.setCurrent (frm); Thread T1 = new thread () {Public runs zero () (recipient ();}}; T1.start (); // txtbox = new textbox ("get lesson", "", 100, textfield.NEW); } Public Zero Command Action (Command C, Disable D) {if (c == cmd_exit) {notifyDestroyed (); }} Public Zero StartApp () {/ * disp.setCurrent (frm); Thread T1 = new thread () {Public runs zero () (recipient ();}}; T1.start (); Public Zero (pauseApp) {} Public Zero-Destroyed Advertising (Boolean Unconditional) {} Public Zero Received () {// When (True) // {String mSenderAddress = ""; Try {msgConn = (MessageConnection) Connector.open ("sms: //: 1234"); Println ("11"); Msg = msgConn.receive (); // Listen and stack until the msg msg system is received. Out.println ("12"); MSenderAddress = msg.getAddress (); // Get the information from the message from where the DMG sentign has been sent to system.out.println ("3"); System.out.println ("Add" + mSenderAddress); System.out.println ("msg aya:" + msg); MsgConn.close (); } Hold (exception e) {System.out.println (e);} if (msg primitive binary message) {// try {msgrev = (binary message) msg) .getPayloadData (); Data = msgrev.toByteArray (); String value = new string (data); Println ("Yahoo"); Println ("yahoo1"); Println (val); (Data); }} Public Zero (Byte [] BS) {try {string str = bs.toString ()} / * stringbuffer D = new stringbuffer (); Bais = new Bytereinputstream (BS); DataInputStream DS = new dataInputTream (bass); Int len ​​= bs.length; Println ("lane =" + lane); If (lane! = 0) {int ch = 0; While ((ch = ds.read ())! = - 1) {d.append ((four) f); }} System.out.println (d); Str = d.toString (); * / //str=bs.toString (); InputStream = this.getClass (). GetResourceAsStream (str); System.out.println ("string is" + str); Im = (Image) Image.createImage (is); Println ("line"); Im1 = (Image) Image.createImage (IM, 0, 0, I, J, Sprut. TRANS_NONE); IMG = new image ("This photo gets sanded", IM1, item. LALUTACATOR, "Koo nohe look", item button); Frm.append (img); } Hold (exception e) {System.out.println (e); }}}}

You are doing some very strange things:

  1. Changing the byte array in a string, especially byte []. ToString ()
  2. Trying to get an input stream by calling the class. Byte array.
  3. Use SMS to send an image

Class.getResourceAsStream () is a string to identify a resource file within the MIDlet jar file.

The correct way to do this is to get a binary message from binary [] and use it to use the image .createImage (bytes, 0, bytes length);

However, as you are sending using SMS, I expected that it was actually a very small image or any person using this app to split a large image on many SMS Will cost more than doing Also be aware that some networks can limit the number of parts between which a SMS can be split between them.

You would be better off providing the functionality provided by MMS.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -