You Are Here:

Community: Developer Discussion Boards

#1 Old Exclamation midlet prob... - 2009-05-09, 22:20

Join Date: Jan 2009
Posts: 2
tosha9
Offline
Registered User
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...
Reply With Quote

#2 Old Exclamation Re: midlet prob... - 2009-05-09, 22:30

Join Date: Jan 2009
Posts: 2
tosha9
Offline
Registered User
My emulator gets hanged.... plz help me...
Reply With Quote

#3 Old Re: midlet prob... - 2009-05-10, 11:01

Join Date: Jun 2007
Posts: 534
Location: Mumbai
Send a message via Yahoo to prakash.raman
prakash.raman's Avatar
prakash.raman
Offline
Super Contributor
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
Reply With Quote

#4 Old Thumbs up Re: midlet prob... - 2009-05-11, 06:48

Join Date: Sep 2008
Posts: 1,195
Location: DELHI
Send a message via Yahoo to jitu_goldie
jitu_goldie's Avatar
jitu_goldie
Offline
Forum Nokia Champion
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..
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
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

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia