| Reply | « Previous Thread | Next Thread » |
|
hi, i need to use one funcyion of midlet to other midlet though every thing is right as syntax nd logic can u please help...
this is my function that works well in single midlet... public void testGET(String url) throws IOException { System.out.println("In testGet...."); HttpConnection connection = null; InputStream is = null; OutputStream os = null; StringBuffer stringBuffer = new StringBuffer(); TextBox textBox = null; connection = (HttpConnection)Connector.open(url); connection.setRequestMethod(HttpConnection.GET); connection.setRequestProperty("IF-Modified-Since","20 Jan 2001 16:19:14 GMT"); connection.setRequestProperty("User-Agent","Profile/MIDP-2.0 Confirguration/CLDC-1.0"); connection.setRequestProperty("Content-Language", "en-CA"); connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); os = connection.openOutputStream(); is = connection.openDataInputStream(); int ch; while ((ch = is.read()) != -1) { stringBuffer.append((char) ch); System.out.println("The buffer:"+stringBuffer); } and this is my call... if (command == Continue) { // write pre-action user code here // write post-action user code here try{ testGET("http://127.0.0.1/surat_blues/testGET.php?type=2"); } catch(Exception e) { System.out.println("nt reachable"); } } Also i have wamp server running also the file is available... |
|
My emulator gets hanged.... plz help me...
|
|
Hi,
Try using this: Code:
public void testGET(String url) throws IOException {
System.out.println("In testGet....");
HttpConnection connection = null;
InputStream is = null;
//OutputStream os = null;
StringBuffer stringBuffer = new StringBuffer();
TextBox textBox = null;
connection = (HttpConnection)Connector.open(url);
connection.setRequestMethod(HttpConnection.GET);
connection.setRequestProperty("IF-Modified-Since","20 Jan 2001 16:19:14 GMT");
connection.setRequestProperty("User-Agent","Profile/MIDP-2.0 Confirguration/CLDC-1.0");
connection.setRequestProperty("Content-Language", "en-CA");
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
//os = connection.openOutputStream();
int responseCode = connection.getResponseCode();
if(responseCode == HttpConnection.HTTP_OK){
is = connection.openDataInputStream();
int ch;
while ((ch = is.read()) != -1) {
stringBuffer.append((char) ch);
System.out.println("The buffer:"+stringBuffer);
is.close();
}
}
you dont have to use output stream as you are not using that. au revoir Prakash Raman |
| prakash.raman |
| View Public Profile |
| Find all posts by prakash.raman |
|
call ur function in run() of thread. Just follow this..
Code:
Thread appthread;
if (command == Continue) {
// write pre-action user code here
appthread = new Thread(runnable)
appthread.start();
// write post-action user code here
}
public void run()
{
try{
testGET("http://127.0.0.1/surat_blues/testGET.php?type=2");
}
catch(Exception e)
{
System.out.println("nt reachable");
}
}
try this and reply.. thanks, jitu_goldie.. KEEP TRYING.. |
| jitu_goldie |
| View Public Profile |
| Find all posts by jitu_goldie |
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| Thread | Thread Starter | Forum | Replies | Last Post |
|---|---|---|---|---|
| Trojan installation onto previous trusted Midlet suite? | guillermoTell | Mobile Java Networking & Messaging & Security | 1 | 2007-05-07 09:40 |
| FAQ (General issues) for Java discussion boards - read this before posting | hartti | Mobile Java General | 2 | 2007-02-06 16:16 |
| Midlet freezes on Nokia 3230 | jawwadhussain | Mobile Java General | 1 | 2006-07-05 08:59 |
| How to create two instances of midlet | marquito99 | Mobile Java General | 0 | 2004-04-30 02:33 |
| launching MIDlet from another MIDlet on 6310i problem | niko86 | Mobile Java General | 1 | 2002-08-07 10:38 |