Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3346622
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:19:33+00:00 2026-05-18T01:19:33+00:00

I have two questions. The first is about updating the UI, the second is

  • 0

I have two questions.

The first is about updating the UI, the second is when I try to connect to the camera to get a mjpeg stream and run getResponseCode(), the app locks there. The MDS shows a lot of data transferring.

I have some classes like ….:

Http extends Thread {
  public abstract String getUrl();
  public abstract String getBase64Encode();
  public abstract void onReturn(int responseCode, InputStream is,int lenght);
  protected abstract void onError(Exception e);
}

CameraHttp extends Http and MjpegHttp extends CameraHttp.

http connects to a URL which is the jpeg or mjpeg camera adresses.

I have a Camera Class. It starts a connection with the overridden method mjpegconnection.go();
I also have a static bitmap on ViewCam screen which extends MainScreen.

After it starts:

url = getUrl();
queryString = encodeURL(queryString);
byte postmsg[] = queryString.getBytes("UTF-8");
httpConnection = (HttpConnection) Connector.open(url
    + ";deviceside=false", Connector.READ_WRITE);
httpConnection.setRequestMethod(HttpConnection.GET);
httpConnection.setRequestProperty("Authorization", getBase64Encode());
os = httpConnection.openDataOutputStream(); 

for (int i = 0; i < postmsg.length; i++) {
    os.write(postmsg[i]);
}
{
     if (!cancel) {
         System.out.println(httpConnection.getURL()+ 
             " *****"+httpConnection.getPort());
         System.out.println("onreturn oncesi"
             + httpConnection.getResponseCode());
         onReturn(httpConnection.getResponseCode(), httpConnection
             .openInputStream(),(int) httpConnection.getLength());

         System.out.println("onreturn sornrası");
     }
     os.close();
     httpConnection.close();
}
} catch (Exception e) {
    System.out.println("hata " + e.getMessage());
    try {
        httpConnection.close();
        Thread.sleep(60);
    } catch (Exception ie) {
}
onError(e);
}

After dosomething

 // decides mjpeg-jpeg stream
 // if it is mjpeg, direct to parser,
 // else it sets image with setImage() and return to connection with go();
 public void parse(InputStream is, int lenght) {
     try {
         if (!type.isMjpegStream()) {
             setImage(is, lenght);
             System.gc();
             StaticVar.ActiveCam.setConnected(true);
         } else { 
             if (parser == null) {
             parser = new JpegParser(is, this);
         } else {
             parser.setInputSteam(is, this);
         }
         parser.parse();
         is.close();
     }
     } catch (Exception e) {
     } 
}

and

 public void setImage(InputStream is, int lenght) {
     byte[] raw = new byte[lenght];
     try {
         is.read(raw);
         currentImage = Bitmap.createBitmapFromBytes(raw, 0, raw.length, 1);
         ViewCam.ViewCam=currentImage;       //static var.
     } catch (IOException e) {
         System.out.println("catche***********");
         // TODO Auto-generated catch block
         e.printStackTrace();
     }
 }

How can I repaint the screen to show the bitmap?

And my ViewCam

public class ViewCam extends MainScreen {
Header header;
String headerString;
public static Bitmap ViewCam;// cam image shows
private static Thread My;// runs connection

void OnStart() {
    My = new Thread() {
        public void run() {
            System.out.println("ONSTART");
            StaticVar.ActiveCam.go();
        };
    };
    My.start();
    Bitmap bitmap = Bitmap.getBitmapResource("res/main.png");
    Bitmap bmp2 = ResizeImage.resizeBitmap(bitmap, Display.getWidth(),
            Display.getHeight());
    Background bg = BackgroundFactory.createBitmapBackground(bmp2);
    this.setBackground(bg);
    this.getMainManager().setBackground(bg);


}


public ViewCam() {
    StaticVar.ActiveCam.getIp();

    OnStart();

    headerString ="Cam View";
    header = new Header("res/bartop.png", headerString, 0);
    add(header);

    ViewCam = Bitmap.getBitmapResource("res/spexco_splash.png");
    ViewCam = ResizeImage.bestFit(ViewCam, Display.getWidth(), Display
            .getHeight());
    BitmapField bf = new BitmapField(ViewCam);
    add(bf);
}
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T01:19:33+00:00Added an answer on May 18, 2026 at 1:19 am

    Try Screen.invalidate()

    public void invalidate(int x, int y, int width, int height)

    Invalidates a region of this screen.
    This method marks a region of this screen as needing a repaint. The repainting is handled later by the main event dispatch thread.

    Note: Any thread can safely invoke this method, and does not require to synchronize on the event lock.

    Overrides:
    invalidate in class Manager
    Parameters:
    x – Left edge of the region in ContentRect coordinates.
    y – Top edge of the region in ContentRect coordinates.
    width – Width (in pixels) of the region.
    height – Height (in pixels) of the region.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

first of all, i like to say that i have read the other two
I have a few questions about the linkage from the following variables. By examples
I have a few questions about git. I have read a couple of documents
I'm about to have to deal with some SQL code in classic ASP VBScript.
I have this method, that can return three different response. At first, it was
This is a two-part question about adding a third-party library (JAR) to an Android
I'm in the process of learning about simulated annealing algorithms and have a few
I have a 22 machine cluster with a common NFS mount. On each machine,
I want to try something different, and am attempting to display an overlay on
I am editing a c# WinForm solution and I do not understand the code

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.