WorldDeveloper.org - Forum Topics http://worlddeveloper.org WorldDeveloper.org 2017 info@astrientlabs.com May 29, 2017 06:57PM UTC WorldDeveloper.org is a managed social network for application developers around the world. Audio in not Recording http://worlddeveloper.org/www/forumtopicview.html?fid=390 390 20 Sep 2011 07:45:22 GMT Actually when i am recording video from mobile camera it is recording as a byte array, after thet through Http coonection i am genarating the .3gp file, but when i am palyaing the .3gp file avideo is playing fine but audio is not playing, when i chacked the descriotion it showing the the video aspect ratio,bitrate ,format,selected codec etc... , but there is no information about Audio. please help me whre i am doing wrong.<br><br>Here is the code to upload the file in server:<br><br>package com.sisatellabs.j2me.job;<br><br>import java.io.ByteArrayOutputStream;<br>import java.io.DataInputStream;<br>import java.io.DataOutputStream;<br><br>import javax.microedition.io.Connector;<br>import javax.microedition.io.HttpConnection;<br><br>import com.sisatellabs.j2me.VideoNote;<br>import com.sisatellabs.j2me.prefs.SystemPreferences;<br>import com.sisatellabs.j2me.ui.CommunicatingScreen;<br>import com.sisatellabs.j2me.ui.LogScreen;<br>import com.sisatellabs.j2me.ui.RecordScreen;<br><br>public class UploadJob implements Runnable<br>{<br>protected String name;<br>protected ByteArrayOutputStream baos;<br><br>public UploadJob(String name, ByteArrayOutputStream baos)<br>{<br><br>this.name = name;<br>this.baos = baos;<br>}<br><br><br>public void run()<br>{<br>VideoNote.instance.display.setCurrent(new CommunicatingScreen());<br><br>HttpConnection c = null;<br>DataInputStream is = null;<br>DataOutputStream os = null;<br><br>try<br>{<br>String uploadURL = VideoNote.instance.getAppProperty("<a href="http://www.sisatel.com">http://www.sisatel.com</a>") + "/socialad/m_input.php";<br>long protocolId = 1L;<br><br>String username = SystemPreferences.instance.get("account.username");<br>String password = SystemPreferences.instance.get("account.password");<br><br>c = (HttpConnection) Connector.open(uploadURL,Connector.READ_WRITE);<br><br>c.setRequestMethod(HttpConnection.POST);<br>c.setRequestProperty("Connection", "keep-alive");<br><br>os = c.openDataOutputStream();<br>os.writeLong(protocolId);<br><br>os.writeUTF(username);<br>os.writeUTF(password);<br>os.writeUTF(name);<br><br>byte[] data = baos.toByteArray();<br>baos.reset();<br>baos = null;<br><br>os.writeInt(data.length);<br>os.write(data);<br>os.flush();<br><br>is = c.openDataInputStream();<br>int rc = is.readInt();<br>}<br>catch (Exception e)<br>{<br>LogScreen.instance.log(e);<br>}<br>finally<br>{<br>if (is != null)<br>{<br>try<br>{<br>is.close();<br>}<br>catch (Exception e)<br>{<br>}<br>}<br>if (c != null)<br>{<br>try<br>{<br>c.close();<br>}<br>catch (Exception e)<br>{<br>}<br>}<br>baos = null;<br>System.gc();<br>}<br><br><br>VideoNote.instance.display.setCurrent(RecordScreen.instance);<br>}<br>}<br><br><br>Here is code of video recording:<br><br>// Java Document<br>package com.sisatellabs.j2me.ui;<br><br>import java.io.ByteArrayOutputStream;<br><br>import javax.microedition.lcdui.Command;<br>import javax.microedition.lcdui.CommandListener;<br>import javax.microedition.lcdui.Displayable;<br>import javax.microedition.lcdui.Graphics;<br>import javax.microedition.media.Manager;<br>import javax.microedition.media.Player;<br>import javax.microedition.media.control.RecordControl;<br>import javax.microedition.media.control.VideoControl;<br><br>import com.sisatellabs.j2me.job.JobRunner;<br>import com.sisatellabs.j2me.job.UploadJob;<br><br><br>public class RecordScreen extends ScreenCanvas implements CommandListener, Runnable<br>{<br>public static final RecordScreen instance = new RecordScreen();<br><br>private Command CMD_START = new Command("Start", Command.BACK, 1);<br>private Command CMD_STOP = new Command("Stop", Command.OK, 1);<br>private Player p = null;<br>private RecordControl rc = null;<br>private VideoControl videoControl = null;<br>private Thread thread;<br>private long startTime = 0;<br><br>private ByteArrayOutputStream baos = new ByteArrayOutputStream(1024*500);<br>private boolean running = false;<br><br>private RecordScreen()<br>{<br>this.addCommand(CMD_STOP);<br>this.addCommand(CMD_START);<br>this.setCommandListener(this);<br>}<br><br>public void initialize()<br>{<br>}<br><br>public void commandAction(Command c, Displayable d)<br>{<br>if (c == CMD_START)<br>{<br>start();<br>}<br>else if (c == CMD_STOP)<br>{<br>stop();<br>}<br>}<br><br>protected void start()<br>{<br>try<br>{<br>if (!running)<br>{<br>if (thread == null)<br>{<br>startTime = System.currentTimeMillis();<br>thread = new Thread(this);<br>thread.start();<br><br>baos.reset();<br><br>p = Manager.createPlayer("capture://video");<br>p.realize();<br>rc = (RecordControl) p.getControl("RecordControl");<br><br><br><br><br>videoControl = (VideoControl) (p.getControl("VideoControl"));<br>videoControl.initDisplayMode(VideoControl.USE_DIRECT_VIDEO, this);<br>videoControl.setVisible(true);<br><br>int x = (getWidth() - videoControl.getDisplayWidth()) >> 1;<br>int y = (getHeight() - videoControl.getDisplayHeight()) >> 1;<br>videoControl.setDisplayLocation(x, y);<br><br><br><br>rc.setRecordStream(baos);<br>p.prefetch();<br><br>rc.startRecord();<br>p.start();<br><br>repaint();<br><br>running = true;<br>}<br>}<br>}<br>catch (Exception e)<br>{<br>LogScreen.instance.log(e);<br>}<br>}<br><br>protected void stop()<br>{<br>if (running)<br>{<br>try<br>{<br>thread = null;<br><br>rc.stopRecord();<br>rc.commit();<br>p.stop();<br>p.deallocate();<br>p.close();<br><br><br><br>JobRunner.instance.run(new UploadJob("sisatelmob.3gpp", baos));<br><br>p = null;<br>rc = null;<br>}<br>catch (Exception e)<br>{<br>LogScreen.instance.log(e);<br>}<br>finally<br>{<br>running = false;<br>}<br>}<br>}<br><br><br>public void run()<br>{<br>while (thread != null)<br>{<br><br><br>try<br>{<br>Thread.sleep(1000);<br>}<br>catch (Exception e)<br>{<br>}<br>}<br>}<br><br>protected void paint(Graphics g)<br>{<br>drawHeaderAndFooter(g," Start recording >");<br><br>int w = getWidth();<br>int h = getHeight();<br><br>int dy = g.getFont().getHeight() + 2;<br>int starty = (h >> 1) - (dy/2);<br><br>if ( running )<br>{<br>long elapsed = (System.currentTimeMillis() - startTime)/1000;<br>String timeString = String.valueOf(elapsed/60);<br>long sec = elapsed % 60;<br>timeString += ( sec 10 ) ? ":0" + sec : ":" + sec;<br><br>g.drawString(timeString, w >> 1, starty, Graphics.TOP | Graphics.HCENTER);<br>}<br>else<br>{<br>g.drawString("Record Ready", w >> 1, starty, Graphics.TOP | Graphics.HCENTER);<br>}<br><br>}<br>}<br><br>Here is the PHP code where file is genarting(m_input.php):<br>$postdata = file_get_contents("php://input");<br>$fp = fopen(time()."-mob.3gp","a+");<br>// fwrite($fp, $GLOBALS['HTTP_RAW_POST_DATA']);<br>fwrite($fp, $postdata);<br>//fclose($fp);<br><br><br>Helese help me where i am doing wrong<br><br>Thank you hi there..Actually i want to edit one small mobile application but i have encountered one problem when i run that application in my mobile... i.e.Unknown application. Could u give some possible solutions....thanks in advance.. http://worlddeveloper.org/www/forumtopicview.html?fid=389 389 6 Jun 2011 13:45:16 GMT <br>// Home Page: <a href="http://members.fortunecity.com/neshkov/dj.html">http://members.fortunecity.com/neshkov/dj.html</a> <a href="http://www.neshkov.com/dj.html">http://www.neshkov.com/dj.html</a> - Check often for new version!<br>// Decompiler options: packimports(3)<br>// Source File Name: AgeCalc2.java<br><br>import java.io.IOException;<br>import java.io.PrintStream;<br>import java.util.Calendar;<br>import java.util.Date;<br>import javax.microedition.lcdui.*;<br>import javax.microedition.midlet.MIDlet;<br><br>public class AgeCalc2 extends MIDlet<br>implements CommandListener<br>{<br><br>public AgeCalc2()<br>{<br>display = Display.getDisplay(this);<br>mMainForm = new Form("AgeCalc");<br>aboutForm = new Form("About Age Calc");<br>msgBox = new Alert("Warning!", "", null, AlertType.ERROR);<br>cDate = new Date();<br>bDate = new Date();<br>cCal = Calendar.getInstance();<br>bCal = Calendar.getInstance();<br>cCal.setTime(cDate);<br>bCal.setTime(bDate);<br>currentDate = new DateField("Pinku", 1);// Here i have edited datafiled name as pinku but actually it was current date.<br>birthDate = new DateField("Birth Date", 1);<br>currentDate.setDate(cDate);<br>birthDate.setDate(bDate);<br>msgBox.setTimeout(-2);<br>ageField = new StringItem("Age:", null);<br>mMainForm.append(birthDate);<br>mMainForm.append(currentDate);<br>mMainForm.append(ageField);<br>mMainForm.addCommand(new Command("Exit", 7, 0));<br>mMainForm.setCommandListener(this);<br>mMainForm.addCommand(new Command("Calculate", 1, 0));<br>mMainForm.setCommandListener(this);<br>mMainForm.addCommand(new Command("About", 1, 0));<br>mMainForm.setCommandListener(this);<br>aboutForm.addCommand(new Command("Back", 2, 0));<br>aboutForm.setCommandListener(this);<br>try<br>{<br>img = Image.createImage("/AgeCalc2.png");<br>ImageItem imageitem = new ImageItem("", img, 3, "img");<br>aboutForm.append(imageitem);<br>}<br>catch(IOException ioexception)<br>{<br>System.out.println("could not create image: " + ioexception);<br>}<br>aboutForm.append(new StringItem("Age Calculator 2.0\nCopyright (c) 2005, All rights reserved.\nBy: Abdelbaset Rabayah\n<a href="http://www.abdelbaset.info">http://www.abdelbaset.info</a>\nEnjoy!", null));<br>}<br><br>public void findAge()<br>{<br>int i = 0;<br>int j = 0;<br>int k = 0;<br>int l = 0;<br>int i1 = 0;<br>int j1 = 0;<br>cCal.setTime(currentDate.getDate());<br>i = cCal.get(5);<br>j = cCal.get(2) + 1;<br>k = cCal.get(1);<br>bCal.setTime(birthDate.getDate());<br>int k1 = bCal.get(5);<br>int l1 = bCal.get(2) + 1;<br>int i2 = bCal.get(1);<br>l = k - i2;<br>if(l1 > j)<br>{<br>l--;<br>i1 = 12 - Math.abs(j - l1);<br>} else<br>{<br>i1 = j - l1;<br>}<br>if(k1 > i)<br>{<br>i1--;<br>switch(j)<br>{<br>case 1: // '\001'<br>case 3: // '\003'<br>case 5: // '\005'<br>case 7: // '\007'<br>case 8: // '\b'<br>case 10: // '\n'<br>case 12: // '\f'<br>j1 = 31 - Math.abs(i - k1);<br>break;<br><br>case 4: // '\004'<br>case 6: // '\006'<br>case 9: // '\t'<br>case 11: // '\013'<br>j1 = 30 - Math.abs(i - k1);<br>break;<br><br>case 2: // '\002'<br>j1 = 28 - Math.abs(i - k1);<br>break;<br>}<br>} else<br>{<br>j1 = i - k1;<br>}<br>String s = "Age: " + l + " years, " + i1 + " months, and " + j1 + " days.";<br>if(k1 1 || k1 > 31)<br>{<br>msgBox.setString("Illegal value!\nPlease check day.");<br>s = "Age:";<br>display.setCurrent(msgBox);<br>}<br>if(l1 1 || l1 > 12)<br>{<br>msgBox.setString("Illegal value!\nPlease check month.");<br>s = "Age:";<br>display.setCurrent(msgBox);<br>}<br>if(i2 0 || i2 > k)<br>{<br>msgBox.setString("Illegal value!\nPlease check year.");<br>s = "Age:";<br>display.setCurrent(msgBox);<br>}<br>ageField.setLabel(s);<br>}<br><br>public void startApp()<br>{<br>display.setCurrent(mMainForm);<br>}<br><br>public void pauseApp()<br>{<br>}<br><br>public void destroyApp(boolean flag1)<br>{<br>}<br><br>public void commandAction(Command command, Displayable displayable)<br>{<br>String s = command.getLabel();<br>System.out.println(s);<br>if(s.equals("Exit"))<br>notifyDestroyed();<br>else<br>if(s.equals("Calculate"))<br>findAge();<br>else<br>if(s.equals("About"))<br>display.setCurrent(aboutForm);<br>else<br>display.setCurrent(mMainForm);<br>}<br><br>private Form mMainForm;<br>private Form aboutForm;<br>private DateField currentDate;<br>private DateField birthDate;<br>private Command exitCommand;<br>private Command calcCommand;<br>private Command aboutCommand;<br>private Command backCommand;<br>private Display display;<br>private StringItem ageField;<br>private Alert msgBox;<br>private Image img;<br>private Calendar cCal;<br>private Calendar bCal;<br>private Date cDate;<br>private Date bDate;<br>}<br> Problem ater editing http://worlddeveloper.org/www/forumtopicview.html?fid=388 388 6 Jun 2011 13:43:28 GMT Hi there...<br>Actually i want to edit one small mobile application but i have encountered one problem when i run that application in my mobile... i.e.Unknown application. Could u give some possible solutions....thanks in advance..<br> HostJ2ME.com Search Proxy http://worlddeveloper.org/www/forumtopicview.html?fid=333 333 26 Aug 2009 16:36:29 GMT Provides search results for the OSM client by aggregating results from Google, Bing, Wikipedia, and Yahoo using the respective search APIs.<br><br>Example Usage:<br><br><pre><br> SearchAgent agent = new SearchAgent();<br> Query query = new Query();<br> query.addHeader("user-agent","MySearchClient"));<br> <br> query.setTerm("volvo xc60");<br> query.setTypes(FileRecord.TYPE_ALL);<br><br> <br> List providers = new ArrayList();<br> providers.add("yahoo");<br> providers.add("live");<br> providers.add("google");<br> providers.add("googlevideo");<br> providers.add("wikipedia");<br><br> BasicUIListable results = agent.find(query,5*1000,100,providers.toArray(new String[0]));<br><br> for ( SearchResult record : results.items(pn,ps) )<br> {<br> System.out.println(record.getTitle());<br> }<br></pre><br><br>Contact me if you need the full source code Need help http://worlddeveloper.org/www/forumtopicview.html?fid=328 328 14 Jun 2009 11:57:11 GMT I downloaded the application but,when opening it,I'm told 'invalid code,get key name' Please advise Midlet Icon Extractor http://worlddeveloper.org/www/forumtopicview.html?fid=309 309 21 Jan 2009 17:13:33 GMT HostJ2ME.com uses the code below to extract application icons from Midlet jars and display them in the HostJ2ME.com midlet directory.<br><br><pre><br>package com.astrientlabs.hostj2me.util;<br><br>import java.io.ByteArrayOutputStream;<br>import java.io.File;<br>import java.io.FileOutputStream;<br>import java.io.IOException;<br>import java.io.InputStream;<br>import java.util.Properties;<br>import java.util.zip.ZipEntry;<br>import java.util.zip.ZipException;<br>import java.util.zip.ZipFile;<br><br>import com.astrientlabs.files.AstrientFile;<br>import com.astrientlabs.util.Strings;<br><br>public class IconExtractor<br>{<br> private String MANIFEST = "META-INF/MANIFEST.MF";<br> <br> public byte[] extract(String path) throws ZipException, IOException<br> {<br> return extract(new File(path));<br> }<br> <br> public byte[] extract(File jarFile) throws ZipException, IOException<br> {<br> ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);<br> ZipFile zipFile = new ZipFile(jarFile);<br> try<br> {<br> /*for ( Enumeration? extends ZipEntry> e = zipFile.entries(); e.hasMoreElements(); )<br> {<br> System.out.println(e.nextElement().getName());<br> }*/<br> <br> ZipEntry entry = zipFile.getEntry(MANIFEST);<br><br> InputStream is = zipFile.getInputStream(entry);<br> if ( is != null )<br> {<br> Properties props = new Properties();<br> props.load(is);<br> <br> String iconFile = props.getProperty("MIDlet-Icon");<br> if ( Strings.isNull(iconFile) )<br> {<br> props.list(System.out);<br> String midlet1 = props.getProperty("MIDlet-1");<br> if ( !Strings.isNull(midlet1) )<br> {<br> String[] parts = midlet1.split(",");<br> if ( parts.length > 2 )<br> {<br> iconFile = parts[1].trim();<br> if ( iconFile.startsWith("/") )<br> {<br> iconFile = iconFile.substring(1);<br> }<br> }<br> }<br> }<br> <br> if ( iconFile != null )<br> {<br> ZipEntry iconEntry = zipFile.getEntry(iconFile);<br> <br> if ( iconEntry != null )<br> {<br> FileOutputStream fos = new FileOutputStream("/tmp/icon.png");<br> InputStream zis = zipFile.getInputStream(iconEntry);<br> int r = 0;<br> byte[] buffer = new byte[4*1024];<br> while( (r = zis.read(buffer)) != -1 )<br> {<br> baos.write(buffer,0,r);<br> fos.write(buffer,0,r);<br> }<br> <br> fos.close();<br> zis.close();<br> }<br> }<br> } <br> }<br> finally<br> {<br> zipFile.close(); <br> }<br> <br> return baos.toByteArray();<br> }<br> <br> public static void main(String[] args)<br> {<br> <br> File jarFile = new File("/projects/workspace/cliqmobile/builds/cliqmobile.jar");<br> IconExtractor extractor = new IconExtractor();<br> try<br> {<br> byte[] data = extractor.extract(jarFile);<br> System.out.println(data.length + " " + AstrientFile.fileType(data));<br> }<br> catch (ZipException e)<br> {<br> // TODO Auto-generated catch block<br> e.printStackTrace();<br> }<br> catch (IOException e)<br> {<br> // TODO Auto-generated catch block<br> e.printStackTrace();<br> }<br> <br> System.exit(0);<br> }<br>}<br></pre> Java Utility for perfrorming DNS Blacklist lookups. For more information on DNSBL see http://en.wikipedia.org/wiki/DNSBL http://worlddeveloper.org/www/forumtopicview.html?fid=308 308 16 Jan 2009 17:43:06 GMT <pre><br>package com.astrientlabs.net.dns;<br><br>import java.util.ArrayList;<br>import java.util.Hashtable;<br>import java.util.List;<br><br>import javax.naming.Context;<br>import javax.naming.NameNotFoundException;<br>import javax.naming.NamingException;<br>import javax.naming.directory.Attribute;<br>import javax.naming.directory.Attributes;<br>import javax.naming.directory.DirContext;<br>import javax.naming.directory.InitialDirContext;<br><br>import com.astrientlabs.prefs.Preferences;<br><br>public class DNSBL<br>{<br> private static String[] RECORD_TYPES = { "A", "TXT" };<br> <br> private DirContext ictx;<br> private List lookupServices = new ArrayList();<br> <br> <br> public DNSBL() throws NamingException<br> {<br> StringBuilder dnsServers = new StringBuilder(""); <br> List nameservers = sun.net.dns.ResolverConfiguration.open().nameservers();<br> for( Object dns : nameservers ) <br> {<br> dnsServers.append("dns://").append(dns).append(" ");<br> }<br> <br> Hashtable env = new Hashtable();<br> env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.dns.DnsContextFactory"); <br> env.put("com.sun.jndi.dns.timeout.initial", Preferences.system.get("dns.timeout","4000"));<br> env.put("com.sun.jndi.dns.timeout.retries", Preferences.system.get("dns.retry","1"));<br> env.put(Context.PROVIDER_URL,Preferences.system.get("dns.url",dnsServers.toString()));<br> <br> ictx = new InitialDirContext(env);<br> }<br> <br> public void addLookupService(String service)<br> {<br> lookupServices.add(service);<br> }<br> <br> public void check(String ip) throws DNSBLException<br> {<br> String[] parts = ip.split("\\.");<br> StringBuilder buffer = new StringBuilder();<br><br> for (int i = 0; i parts.length; i++)<br> {<br> buffer.insert(0, '.');<br> buffer.insert(0, parts[i]);<br> }<br> <br> ip = buffer.toString();<br> <br><br> <br> Attribute attribute;<br> Attributes attributes;<br> <br> <br> String lookupHost;<br> for ( String service : lookupServices )<br> {<br> lookupHost = ip + service;<br> try<br> {<br> attributes = ictx.getAttributes(lookupHost, RECORD_TYPES);<br> attribute = attributes.get("TXT");<br> <br> if ( attribute != null )<br> {<br> throw new DNSBLException(lookupHost + ": " + attribute.get());<br> }<br> }<br> catch (NameNotFoundException e)<br> {<br> //this is good<br> //LogWriter.system.log(getClass(),e);<br> }<br> catch (NamingException e)<br> {<br> //LogWriter.system.log(getClass(),e);<br> }<br> }<br> }<br> <br> <br> public static void main (String[] args)<br> {<br> <br> <br> try<br> {<br> DNSBL dnsBL = new DNSBL();<br> <br> dnsBL.addLookupService("blackholes.easynet.nl");<br> dnsBL.addLookupService("cbl.abuseat.org");<br> dnsBL.addLookupService("proxies.blackholes.wirehub.net");<br> dnsBL.addLookupService("bl.spamcop.net");<br> dnsBL.addLookupService("sbl.spamhaus.org");<br> dnsBL.addLookupService("dnsbl.njabl.org");<br> dnsBL.addLookupService("list.dsbl.org");<br> dnsBL.addLookupService("multihop.dsbl.org"); <br> dnsBL.addLookupService("cbl.abuseat.org"); <br> <br> try<br> {<br> dnsBL.check("201.223.47.44");<br> }<br> catch (DNSBLException se)<br> {<br> System.out.println(se.getMessage());<br> }<br> <br> try<br> {<br> dnsBL.check("38.100.193.183");<br> }<br> catch (DNSBLException se)<br> {<br> System.out.println(se.getMessage());<br> }<br> <br> try<br> {<br> dnsBL.check("189.94.149.137");<br> }<br> catch (DNSBLException se)<br> {<br> System.out.println(se.getMessage());<br> }<br> <br> try<br> {<br> dnsBL.check("220.227.113.25");<br> }<br> catch (DNSBLException se)<br> {<br> System.out.println(se.getMessage());<br> }<br> <br> <br> <br> }<br> catch (Exception e)<br> {<br> e.printStackTrace();<br> }<br> <br> System.exit(0);<br> }<br>}<br>class DNSBLException extends Exception<br>{<br><br> public DNSBLException()<br> {<br> super();<br> }<br><br> public DNSBLException(String message, Throwable cause)<br> {<br> super(message, cause);<br> }<br><br> public DNSBLException(String message)<br> {<br> super(message);<br> }<br><br> public DNSBLException(Throwable cause)<br> {<br> super(cause);<br> }<br>}<br></pre> Line Wrapping Utility for Drawing Strings on a Canvas http://worlddeveloper.org/www/forumtopicview.html?fid=44 44 29 Jan 2007 20:14:22 GMT <pre><br>/*<br> * Copyright (C) 2006 Astrient Labs, LLC Licensed under the Apache License,<br> * Version 2.0 (the "License"); you may not use this file except in compliance <br> * with the License. You may obtain a copy of the License at <br> * <br> * <a href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</a> <br> * <br> * Unless required by applicable law or agreed to in writing, software <br> * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT <br> * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the <br> * License for the specific language governing permissions and limitations under<br> * the License.<br> * <br> * Astrient Labs, LLC <br> * <a href="http://www.astrientlabs.com">www.astrientlabs.com</a> <br> * rashid@astrientlabs.com<br> * Rashid Mayes 2006<br> */<br>package com.astrientlabs.text;<br><br>import java.util.Enumeration;<br>import java.util.NoSuchElementException;<br><br>import javax.microedition.lcdui.Font;<br>import javax.microedition.lcdui.Graphics;<br><br>public class LineEnumeration implements Enumeration<br>{<br> private Font font;<br><br> private String text;<br> private int width;<br> private int position;<br> private int length;<br> private int start = 0;<br><br> public LineEnumeration(Font font, String text, int width)<br> {<br> this.font = font;<br> this.text = text;<br> this.width = width;<br> this.length = text.length();<br> }<br><br> public boolean hasMoreElements()<br> {<br> return (position (length - 1));<br> }<br><br> public Object nextElement() throws NoSuchElementException<br> {<br> try<br> {<br> int next = next();<br><br> String s = text.substring(start, next);<br> start = next;<br><br> if (text.length() - 1 > start && (text.charAt(start) == ' ' <br> || text.charAt(start) == '\n'))<br> {<br> position++;<br> start++;<br> }<br><br> return s;<br> }<br> catch (IndexOutOfBoundsException e)<br> {<br> throw new NoSuchElementException(e.getMessage());<br> }<br> catch (Exception e)<br> {<br> throw new NoSuchElementException(e.getMessage());<br> }<br> }<br><br> private int next()<br> {<br> int i = position;<br> int lastBreak = -1;<br><br> for (; i length <br> && font.stringWidth(text.substring(position, i)) = width; i++)<br> {<br> if (text.charAt(i) == ' ')<br> {<br> lastBreak = i;<br> }<br> else if (text.charAt(i) == '\n')<br> {<br> lastBreak = i;<br> break;<br> }<br> }<br><br> if (i == length)<br> {<br> position = i;<br> }<br> else if (lastBreak == position)<br> {<br> position++;<br> }<br> else if (lastBreak position)<br> {<br> position = i;<br> }<br> else<br> {<br> position = lastBreak;<br> }<br><br> return position;<br> }<br><br> public int writeTo(Graphics g, int startx, int starty, int maxY, Font font)<br> {<br> int fontHeight = font.getHeight() + 1;<br><br> while (hasMoreElements() && starty maxY)<br> {<br> g.drawString(String.valueOf(nextElement()).trim(), <br> startx, starty, Graphics.TOP | Graphics.LEFT);<br> starty += fontHeight;<br> }<br><br> return starty;<br> }<br><br> public void reset()<br> {<br> start = 0;<br> position = 0;<br> }<br>}</pre> download reporting http://worlddeveloper.org/www/forumtopicview.html?fid=270 270 30 Sep 2008 07:26:23 GMT I need to know how the hostj2me server manages to log the mobile configuration, profile,and the model number of the phone which downloads a mobile application from its server....How is it possible to query the phone OTA.......<br> I need some code post on this http://worlddeveloper.org/www/forumtopicview.html?fid=194 194 14 Nov 2007 09:16:21 GMT I wrote a Time Table midlet using persistence storage API for university students to save course code with time. I want the midlet to alert the user when they have that particular course or some minutes before even when the midlet is closed. I need some code post on this. Thanks