GSM Shop GSM Shop
GSM-Forum  

Welcome to the GSM-Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features.
Only registered members may post questions, contact other members or search our database of over 8 million posts.

Registration is fast, simple and absolutely free so please - Click to REGISTER!

If you have any problems with the registration process or your account login, please contact contact us .

Go Back   GSM-Forum > Other Gsm/Mobile Related Forums > Java, iOS, Android, Symbian development


Java, iOS, Android, Symbian development No SIS,JAVA,IPA Files to download here, this section is created to those who are Interesting in Programming JAVA,Android,iOS or Symbian Applications.

Reply
 
LinkBack Thread Tools Display Modes
Old 08-18-2004, 22:54   #1 (permalink)
Junior Member
 
Join Date: Oct 2003
Posts: 32
Member: 42877
Status: Offline
Thanks Meter: 0
Problems making a connection as a thread


Hi

I'm finishing my app and i have a pair of new problems. As i've seen in tutorials and other apps i use a main class who implements the midlet interface and the other screens are soons of Form, Canvas, List,... being the main class the one who decide which one is the current screen. But i have 2 problems.

How can i show an alert form a not main class?
I want to download some images from a not main class, and the class who makes the conection must be a thread, so i've made a method in the main class how returns the byte[] with the data, this method runs the thread and show a Canvas class how inform to the user that the app is connecting and permit to the user cancel the connection but here the problem. I don't know how to return to the Form class the byte[] with the data.

Sorry for my bad english and i hope u could answer my question. If u don't understand something or have any problem i'll try to explain it better

Thanks

Adrián
  Reply With Quote
Old 08-24-2004, 08:56   #2 (permalink)
Junior Member
 
Join Date: Mar 2004
Age: 44
Posts: 21
Member: 57585
Status: Offline
Thanks Meter: 0
To show an Alert or any other Displayable you need a reference to the display object, and optionaly a reference to the next Displayable object. You can pass them to the "non main class" by its constructor/set method/...

To return the images use a Vector of byte[] inside the Runnable class, and an indicator that check if the imageas downloaded.
Code:
class MyProgressCanvas extends Canvas implements Runnable {

  public boolean running = false;
  public Vector result = new Vector();
  private String[] imageURLs = {"...","...",...};
  private boolean interrupted = false;

  void run() {
    running = true;
    index = 0;
    while (index < imageURLs.length) && (!interrupted) {
      // create new byte[]
      // download image to the byte array
      // add array to the vector
      // update the progress bar or whatever and repaint
      index++;
    }
    running = false;
  }

  void paint (Graphics g) {
    // paint whatever you want
  }
  
  void keyPressed(int keyCode) {
    // set interrupted to false at certain keypress
  }
}
In the main class create this object, make it current and make a loop that wait until its running field became false, then use the Vector field for any purpose.
  Reply With Quote
Reply

Bookmarks


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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with CYCLONE BOX It connects As Boot-laoder Mode But doesnt change Mode... malikzahidawan Cyclonebox 3 09-06-2009 22:22
problem when try to make sx4 connection alfares2007 MXKEY Nokia Flasher and Unlocker (by Alim Hape) 5 05-25-2009 05:10
Mapping USB active sync connection as Packet/cellular data connection mujeeb HTC & PDA WM( With Touchscreen) 0 04-30-2009 21:19
can't make replay / post in this thread GsmTracer Board, Server and Login Problems/Support 0 05-21-2008 21:30
Please make an new DB2020 unlocking thread - be a moron! m_dige Cruiser Suite 2 05-12-2007 19:23


All times are GMT +1. The time now is 00:37.



Powered by Searchlight © 2024 Axivo Inc.
vBulletin Optimisation provided by vB Optimise (Pro) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
- GSM Hosting Ltd. - 1999-2023 -
Page generated in 0.18354 seconds with 9 queries

SEO by vBSEO