Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Highlighted
Developer
Posts: 41
Registered: ‎08-05-2008
My Device: Not Specified

Re: Automatically running application on start

if you dont need to display any UI you can use Application instead of UiApplication.

Also try doing the task using invokeLater()

Contributor
Posts: 38
Registered: ‎03-18-2010
My Device: 9000
My Carrier: Telekom.de/Vodafone.de

Re: Automatically running application on start

[ Edited ]

Hi,

 

@madhurvyas1

I've done so. My code looks now like this:

 

 

package copyXML;

import net.rim.device.api.system.Application;



public class copyXMLApplication extends Application {
	
	public copyXMLApplication() {
		//copyXMLMainScreen mainScreen = new copyXMLMainScreen();
		//pushScreen(mainScreen);
	}
	
	public static void main(String[] args) {
		copyXMLApplication app = new copyXMLApplication();
		app.enterEventDispatcher();
	}
}

 

package copyXML;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;

import javax.microedition.io.Connector;
import javax.microedition.io.HttpConnection;

import javax.microedition.io.file.FileConnection;


import net.rim.device.api.system.Application;
import net.rim.device.api.ui.MenuItem;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.component.Menu;
import net.rim.device.api.ui.container.MainScreen;

public class copyXMLMainScreen  {
	private String url = "http://myserver/myfolder/test.xml";
	private String method = "GET";
	private DataInputStream xmlFile = null;
	StringBuffer stringBuffer;
	int _c;
	String localFilePath = "file:///store/home/user/documents/test.xml";
	
	public copyXMLMainScreen(){
		//Thread copyThread = new Thread(){
		Application.getApplication().invokeLater(new Runnable(){
			public void run(){
				while (true){
					try{
						Thread.sleep(120000);
						copyFile();
						Thread.sleep(300000);
					}catch (InterruptedException ie){
						
					}catch(IOException e){
						
					}
				}
			}
		});
		//copyThread.start();
	}	
		
	public void copyFile() throws IOException{
		HttpConnection connection = (HttpConnection)Connector.open(url);
		connection.setRequestMethod(method);
		
		int responseCode = connection.getResponseCode();
		if (responseCode != HttpConnection.HTTP_OK){
			Dialog.inform("Fehler");
			return;
		}
					
		DataInputStream responseData = connection.openDataInputStream();
		xmlFile = responseData;
		
		try{
			FileConnection fcLocal = (FileConnection) Connector.open(localFilePath, Connector.READ_WRITE);
			if (!fcLocal.exists()) {
                fcLocal.create();
            }
			DataOutputStream dos = fcLocal.openDataOutputStream();
			_c = xmlFile.read();
				
			while (_c !=-1){
				dos.write(_c);
				_c=xmlFile.read();
			}
			dos.flush();
			dos.close();
			fcLocal.close();			
		}catch(IOException ex){
			System.out.println(ex.getMessage());
		}
		connection.close();		
	}
}

 

 

But didn't help. The application does not start automatically.

 

@all

I've also tried to attach my device to the debugger, but this also doesn't work. There are obviously some files missing. For example "net_rim_app_manager.debug", "net_rim_cldc.debug" and some more. Do I have to install something additional to use the debugger with my device?

Developer
Posts: 723
Registered: ‎03-12-2009
My Device: Playbook

Re: Automatically running application on start

Ignore those prompts, you don't need those files.

 

Do you have the debugger setup to break on any exception?

 

 

Contributor
Posts: 38
Registered: ‎03-18-2010
My Device: 9000
My Carrier: Telekom.de/Vodafone.de

Re: Automatically running application on start

Sorry, that I didn't answer until now, but there had other things to be done until now...

 

Now I tried to attach the BlackBerry to the Debugger on Startup and everything seems to be good. There comes a prompt up, that asks for my password. Then the warnings come up, that there are files missing. There I click "Don't ask me again" and then there is another error message with the following text:

 

"No debug information found for module "net_rim_cldc". Please ensure that you have installed the simulator package that matches the handheld code you are attempting to debug."

 

I use a BB 9000 an I have installed the matching simulator, too. Where could the problem be?

 

Thanks a lot!

Contributor
Posts: 38
Registered: ‎03-18-2010
My Device: 9000
My Carrier: Telekom.de/Vodafone.de

Re: Automatically running application on start

No ideas?