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
Contributor
Posts: 24
Registered: ‎07-13-2011
My Device: 9780

Beginner java query

Hi

 

I know enough about java to get me into some trouble, but am battling with some basic programming that I can't see how do do it on a Blackberry.  If I can just get some help with this syntax then I can work my way forward again.  If anyone feels so kind to assist it will be gratefully appreciated.

 

REQUIRE : a BB Java program that will automatically send an email to a preset email address at a scheduled interval (say every 1000 seconds) - see below.

 

I am providing the basic structure of a program - all I am asking is for someone to fill in the missing part ( and make corrections to the template where necessary)

 

I know it involves the -  timer.schedule(new TimerTask()  and a number of email commands - but then I get lost 

 

Many thanks

 

// MASTER start program

import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.system.*;
import net.rim.blackberry.api.invoke.*;
import net.rim.blackberry.api.mail.*;

 

//=======Class STaRT (Start up Program)=================

public class STaRT extends UiApplication
{
    public static void main( String[] inArgs )
  {
 STaRT bbApp = new STaRT();
 bbApp.enterEventDispatcher();
  }

    public STaRT() {   }
   
    public void activate()
  { this.pushScreen(new MainPRG());}
 
}


//=======Class MaimPRG (Main Program)=================


class MainPRG extends MainScreen

{

public MainPRG()
 {
        super();
        this.initialize();
     }

public void close()
     {
        Dialog.alert( "Closing the app" );
        super.close();
     }

 


// set a timer, scheduled every 1000 seconds, to send an email with subject "Scheduled text message' to a set email address abc@myname.com

 


}

 

 

 

Developer
Posts: 19,612
Registered: ‎07-14-2008
My Device: Not Specified

Re: Beginner java query

This is a big bit to attempt to take at one time.

 

I suggest you actually build this program up in bits.  Take one of the sample programs, strip out all the bunf you don't need, and just have it displaying a simple screen.  Then get it to send emails.  This KB article should help.

 

http://supportforums.blackberry.com/t5/Java-Development/Sending-email-messages/ta-p/442790

 

Then try to initiate this to happen, from the screen repeatedly, using a TimerTask as you suggest.  lastly, try to get this running in the Background. 

 

Work through this, I suspect you will get stuck at the last point, but when you get there, please bump us again.

 

Good luck. 

Contributor
Posts: 24
Registered: ‎07-13-2011
My Device: 9780

Re: Beginner java query

Many thanks for the fast reply

 

What you have answered is what I had experienced, and thought I may be on the wrong path and there may be a quicker way of doing it.  I have written programs to send emails, as well as others to undertake scheduled activities, but not two activities in one program.

 

Is it possible, in just a very few descriptive lines, to someone to just explain the basic  structure of how this is done?  I will be able to do the programming after that

 

Thanks again for the support

 

Brian

Developer
Posts: 434
Registered: ‎07-23-2012
My Device: Blackberry 10

Re: Beginner java query

Few points
1.    Explore background apps.
2.    Thread
3.    Invoke api
4.    And example send in above post

Thanks
-------------------------------------------------------------------------------------
Press the Accept as solution Button when u got the Solution
Press Kudo to say thank to developer.
-------------------------------------------------------------------------------------.