need help: get SMS data in application

I started an SMS application, here is the code for displaying the TEXT in my application, as soon as the phone receives an SMS. I looked at this thread: http://supportforums.blackberry.com/t5/Java-Development/SMS-Application/m-p/63948 , but I still couldn't get it to work. Any ideas? Thank you very much!

import net.rim.device.api.ui.UiApplication;

public class ShowSMS extends UiApplication {

    public static void main(String[] args) {
        ShowSMS app = new ShowSMS();
        app.enterEventDispatcher();
    }

    public ShowSMS() {
        ShowSMSScreen mainScreen = new ShowSMSScreen();
        pushScreen(mainScreen);
    }
}
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.container.MainScreen;

public class ShowSMSScreen extends MainScreen{

    public ShowSMSScreen(){
        add(new LabelField("waiting text msg"));

        ListeningThread thread = new ListeningThread(this);
        thread.start();
    }

    public void addLabelFiled(String text) {
        add(new LabelField(text + "\n"));
        }
}
import java.io.IOException;
import javax.microedition.io.Connector;
import javax.microedition.io.Datagram;
import javax.microedition.io.DatagramConnection;

public class ListeningThread extends Thread { 

    ShowSMSScreen mainScreen;
    public ListeningThread(ShowSMSScreen mainScreen) {
    this.mainScreen = mainScreen;
    }
    public void run() {
        try { 

       DatagramConnection _dc = (DatagramConnection)Connector.open("sms://");
                    for(;;)
                {
         Datagram d = _dc.newDatagram(_dc.getMaximumLength());
                       _dc.receive(d);
                       byte[] bytes = d.getData();
                       String address = d.getAddress();
                       String msg = new String(bytes);
                       mainScreen.addLabelFiled(address);
                       mainScreen.addLabelFiled(msg);
           }
      } catch (IOException e) {
               System.err.println(e.toString());
      }
 }
}

To develop on the post of Mark, what you do above runs the datagram receiver in the thread of the event, which is strictly verboten. Any blocking operation performed on the event thread can / will cause the event queue to overflow, resulting in an exception "the program is not responding.

Conversely, you CANNOT access the user interface of a backgropund thread - only from the event thread.

Thus, you need to separate these two. You can start a thread to handle the datagram, then use invokeLater() in this thread to place your data on the user interface.

Tags: BlackBerry Developers

Similar Questions

  • Need help get Photoshop CC 2015.0.0 update to 2015.1.1

    Need help get Photoshop CC 2015.0.0 update to 2015.1.1. I bought Adobe CC and installed on my Windows 7, 64-bit PC 19 February 2016. I've uninstalled and reinstalled Photoshop CC and failed to get the update. I checked updates of the app, refreshed and disconnected and signed in CC. Creative cloud still sees the 2015.0.0 as being the updated version. Help, please! Thank you!

    Penny

    Penny

    Please delete these two folders - C:\Users\\AppData\Local\Adobe\ MAA UPDATER and OOBE times

    In case if you have any type of firewall blocking Adobe then it won't work, to check and confirm the Solution 3 follow the following link: Adobe Creative Cloud apps reverts after 2015 updated CC test

  • Need help get data with the most recent date of entry into

    Hey guys;

    I need help with fine tuning a query to get the one with the most recent implementation.

    Here's my current query:

    /**********************************************
    Select sge.seal_group_id,
    SGE.equipment_id,
    SGE.effective_date
    of seal_group_equipment EMS.
    seal_group sg
    where equipment_id = 48801
    AND EMS. SEAL_GROUP_ID = SG. SEAL_GROUP_ID
    and sge.end_date is null
    Group of sge.equipment_id, sge.seal_group_id, sge.effective_date
    After having sge.effective_date = max (sge.effective_date)

    ******************************************************/

    Which produces the following results:
    SEAL_GROUP_ID - EQUIPMENT_ID - EFFECTIVE_DATE
    25-48801 - 01/01/1993-00: 00:00
    11730-48801 - 22/08/2003 08:42:11


    What I really need, is to show only the line with the most recent date of entry into
    I hope someone can help
    Thank you

    MAX will not work because the SEAL_GROUP_ID could depart. I would say analytical:

    select seal_group_id,
    equipment_id,
    effective_date
    from (
    select sge.seal_group_id,
    sge.equipment_id,
    sge.effective_date,
    RANK() over (partition by equipment_id order by effective_date desc) r
    from seal_group_equipment sge,
    seal_group sg
    where equipment_id = 48801
    AND SGE.SEAL_GROUP_ID = SG.SEAL_GROUP_ID
    and sge.end_date is null)
    where r = 1;
    

    Keep in mind if two records have the same effective_date, they would both appear.

    Note: query above has not been tested, since there is no script provided.

  • Need help with the data storage store, local array and network connections

    Need help with my ESXi 4.1 installation

    My hardware:

    I built a server with an Asus P6T whitebox, i7 920, 12 Gig RAM, NIC, Intel Pro1000 PT Quad, 3ware 9650SE-12ML with 8 1.5 TB SATA green in a raid 6 array gives me about 8 + TB with a spare drive all housed within a NORCO RPC-4220 4U Rackmount Server chassis.  I also have a 500 GB SATA drive which will hold the ESXi and virtual machines.

    The network includes a firewall, Netgear Prosafe FVS336G, GS724Tv of Netgear ProSafe 24 port Gigabit Managed Switch on a dhcp cable modem internet service provider.

    I also have 2 old NetGear SC101T NAS disks (4to) I want to connect to the system how some - at a later date have... data on them and want to transfer to the new storage array. I always looking into the question of whether they will work with ESXi 4.1, or I might have to only access it through Windows XP.

    My Situation:

    I have already installed ESXi 4.1 and vsphere client with no problems and it is connected to a dhcp cable internet service.  I've set up host via a dynamic DNS service name give me a static hostname on the internet.  I installed three machines to virtual OS successfully at the moment and now want to first start by creating a multimedia storage server which will use some of this new 8 TB array, then separate data storage for use with a web server small overhead storage and a backup.  It is a domestic installation.

    Help with the data store and network:

    I was doing some reading, because I'm new to this, and it looks like I'll probably want to set up my table via ESXi as a nfs disk format.  Now, the data store is usually in another physical box from what I understand, but I put my readers and ESXi all in the same box.  I'm not sure that the best way to put in place with grouped network cards, but I want to make this work.

    I understand that in ESXi 4.1 using iSCSi LUN must be less than 2 TB, but nfs - I should be able to add a bigger partition then 2 TB (for my multimedia) in nfs, right? or should I still add it separately as a separate 2 TB drives and then extend them to get the biggest space.

    Any suggestions or direct resources showing examples on how to actually add some parts of the table as data warehouses separate nfs.  I know that to go to the configuration tab, and then select Add to storage, and then select nfs. I have not my picture, but it's here that I don't know what to do because ESXi 4.1 system already has an address, should I put the same thing to the new data store array also (will it work?), and what should I use for the name of the folder and the store of data... just do something to the top.  I thought to later install Openfiler (for a multimedia storage using this table server) as a virtual machine, use the table with esxi so that I can access the same storage space with widows and linux-based systems.

    I also know I have to find a way to better use my quad nic card... put in place of virtual switches, grouping, etc HELP?

    Any direction, assistance, similar facilities to sample, suggestions or resources that would help would be great. I did a lot of hunting, but still a little confused on how to best to put in place.

    You must think of VMDK files of large databases with records of random size guest go read some data (a DLL or an INI file), maybe write some data back, then go read other data. Some files are tiny, but certain DLLs are several megabytes. It's random i/o all and heavy on the search time. IO Opsys is small random operations that are often sequential (go read data, write data, go read other data,...) so that deadlines are critical to the overall performance. That's why people say OPS are / s of reference and forget the MBs flow. The only time where you bulk transfers are when you read media (ISO files).

    Well, now forget all this. Actually the disk activity will depend on the specific applications (database? mail server? machines compiler?), but the above is true for boots, and whenever applications are idle. You should see the profile to know.

    RAID 10 is faster (and often more reliable) than RAID 5 or RAID-6 except in certain specific cases. In General RAID 10 is ideal for many random writes, since the calculation of parity for RAID-5 and - 6 adds to the overall latency between command and response - latency is cumulative if a little slow here and a little slow it adds up to a lot of overall slow synchronous especially with e/s on a network. OTOH RAID-5 and -6 can produce faster readings due to the number of heads, so you can use it for virtual machines that transfer bulk. Test. You may find that you need several different types subdashboards for best results.

    You said 3ware, they have some good grades on their site, but don't believe it. With my 9650 that I found myself with only a couple of their recommendations-, I put the (simple) table for allocation size 256 k, nr_requests at 2 x the queue_depth and use the planner date limit. I had the habit for the Ext4 file system formatted with stride and stripe-width synced to the table and used the options large_files with fewer inodes (do not use the huge_files option unless you plan to have single VMDK files in the terabyte range). Use a cache of great reading in advance.

    Virtual machines use VMDK files in all cases except raw iSCSI LUN that they treat native disks. VMDK is easier to manage - you can make a backup by copying the file, you can move it to a PC and load it into another flavour of VMware, etc. There could be some features iSCSI to your San as a transparent migration but nothing for me. NFS has less chatter of Protocol if latency lower times to complete an operation. NFS is good to read and write a block of data, that's all it boils down to.

    UPS is good, but it won't help if something inside the machine explodes (UPS does nothing if the PC power supply goes down). If the RAID card has an option for a battery backup module, so it can contain some writings in memory and may end up the disk i/o after replacing the power supply. 3ware also limits the types of caching available if help is not installed, and you get just the right numbers with the module.

  • WebServices - need help getting started...

    Hi all

    I am fairly new to Web services and Coldfusion I could use some help getting started. Creating the Web service has already been made, so I need to create a new one, so that the part is already done.  The existing webservice is written in .NET and I need to consume using Coldfusion. I think I have all the information I need from the creator (s) in the various XML files. There are a few examples of applications in the .xml file format in the information that was given, as well as a wsdl.xml file. Of my reading on Coldfusion and Web services is that they are consumed by the...

    < cfinvoke webservice = "yada.wsdl" method = "use" returnvariable = "returnedVal" > "

    and send arguments through

    < cfinvokeargument

    to the Web service that returns the data.

    But t that's where I'm wrong... It seems I should use the wsdl.xml file to connect to the Web service... is that correct? I have to place the wsdl.xml outside the Web root in IIS?

    Any suggestions are appreciated.

    If you try to refer to this wsdl file:

    Directory containing wsdl.xml

    .../wwwroot/mydir/WSDL.Xml

    Then, you must use a parameter like this:

    method http://localhost/mydir/WSDL.xml"="mywsdlmethod"returnvar ="data">

    « ? WSDL"is a ColdFusion function that uses the ability of ColdFusion to generate a wsdl file dynamically on the fly from a SWC file that is configured to be a web service.

  • need help with xml data

    Hi all

    need your spiritual help once more!
    I have a table 'product' as below:

    create table product)
    product_id number (2),
    product_info varchar (4000));

    Select * from product:
    product_id product_info
    1 < ticketing > < product = 'TV' > < productservice = "shipping" > < / productservice > < / product = 'TV' > < / ticket >

    I need to get the column product_info information in a new table with 2 columns product and productservice product_details. as in: -.
    Select * from product_details:
    product_id product productservice
    1 expedition TV

    any suggestions on how to do it.
    PS-> for a product it can be several services and there may be several products for a ticket.

    Your XML file is not well formed at all (so many errors in there).

    However, if you had a valid XML code, you could do something like that...

    SQL> ed
    Wrote file afiedt.buf
    
      1  with t as (select 1 as product_id, '' as product_info from dual union all
      2             select 2, '' from dual)
      3  --
      4  -- end of test data
      5  --
      6  select t.product_id, x.*
      7  from t
      8      ,xmltable('/ticketing/product'
      9                passing xmltype(t.product_info)
     10                columns product varchar2(10) path '/product/@name'
     11                       ,service varchar2(15) path '/product/productservice/@name'
     12*              ) x
    SQL> /
    
    PRODUCT_ID PRODUCT    SERVICE
    ---------- ---------- ---------------
             1 TV         shipping
             2 VCR        delivered
    
  • need help for calculation date

    I need help with this:

    I added successfully a document level script to add the date printed in my document

    this.getField("DatePrinted").value = util.printd ("mm/dd/yy", new Date());

    I now need to fill in a field named "Date" with a date that is 14 days after the date of DatePrinted.

    and I'm lost.

    Can anyone help?

    Get the current date/time

    var d = new Date();

    Add 14 days

    d.setDate (d.getDate () + 14);

    Set a field value

    getField("Deadline").value = util.printd ("mm/dd/yy", d);

    That last part may need to be changed depending on where you place the script. If it's the same script at the document level, the whole thing can be:

    Get the current date/time

    var d = new Date();

    Set a field value

    getField("DatePrinted").value = util.printd ("mm/dd/yy", d);

    Add 14 days

    d.setDate (d.getDate () + 14);

    Set another value of field

    getField("Deadline").value = util.printd ("mm/dd/yy", d);

  • Need help with the date of Validation Urgent

    Hello

    We need help in the Validation Date.

    We have 2 fields of Date on the form the Start Date, End Date

    The requirement is: End Date (cannot be more than 30 years as of the start date).

    I wrote after the script on the exit eventof the End Date . But the problem is its calculation of 30 years from the current Date not from the Start Date

    var

    tDate = util.scand (' mm/dd/yyyy', new Date());

    var

    M = tDate.getMonth ();

    var

    D = tDate.getDate ();

    var

    Y = tDate.getFullYear ();

    var

    SRes = util.printd("yyyy-mm-dd", new Date((Y+30), M,D) );

    App.Alert (SRes)

    If

    (SRes < = this.rawValue)

    {

    App.Alert ("cannot be greater than 30 years from the start date")

    () xfa.host.setFocus

    ce );

    }

    can someone help me please

    Kind regards

    Jay

    Hello

    You need to get the LCD field javascript and calculate & compare with the future date in date javascript.

    Try the following script.

    var sDate = StartDate.rawValue;
    var wkStartDate = util.scand ("yyyy-mm-dd", sDate);

    nYear var = wkStartDate.getFullYear ();
    nMonth var = wkStartDate.getMonth ();
    nJour var = wkStartDate.getDate ();

    var wkFutureDate = new Date (+ 30 nYear, nMonth, nJour);

    sDate = EndDate.rawValue;
    var wkEndDate = util.scand ("yyyy-mm-dd", sDate);

    If (wkEndDate.getTime () > wkFutureDate.getTime ()) {}
    xfa.host.messageBox ("cannot be more than 30 years from the start date");
    xfa.host.setFocus (this);
    }

  • Need help getting A value in My App using xml/php http request

    I know that maybe this isn't the place to ask questions about php, but I thought that people may have encountered a similar problem and I'm getting desperate basically my application's data is stored in a mysql database table, and what I have to do is to get the value of auto increment of this table in my application via an http request. I'm doing a php file that gets this value and displays this value in the xml format, but I'm terrible at creating php to do such things and just get the constant errors. Can someone take a look at this and help me to tweak it so it does what I want it please? The table in question is called links and the line/field/column in the table I'm after is called linkid. This is the next value of auto-increment this line printed in xml format, that's what I want. Here is the php so far:-

    <?php 
    header("Content-type: text/xml"); 
    $host = ""; 
    $user = ""; 
    $pass = ""; 
    $database = ""; 
    $linkID = mysql_connect($host, $user, $pass) or die("Could not connect to host."); 
    mysql_select_db($database, $linkID) or die("Could not find database."); 
    $tablename   = "links";
    $next_increment  = 0;
    $qShowStatus   = "SHOW TABLE STATUS LIKE '$tablename'";
    $qShowStatusResult  = mysql_query($qShowStatus) or die ( "Query failed: " . mysql_error() . "<br/>" . $qShowStatus );
    $row = mysql_fetch_assoc($qShowStatusResult);
    $next_increment = $row['Auto_increment'];
    echo "next increment number: [$next_increment]"; 
    ?>
    

    Hello

    step 1. the customer wants to add a new record. and sends a request for a new record

    step 2. the server adds a new record in the database (now its Blanck) and returns its ID number

    step 3.  the customer has now has an appropriate identification number and use it to add a new object to the table

    step 4. the customer with a registration ID and the new data for this "empty folder" is an update not an insert.

    step 5. You now have the table and database synchronization.

    David.

  • Need help with coversion date

    Hello

    I have a date format that is varchar2 and value is as on 2009-03 - 31.i need to convert to date and it must be as on 31 March 09

    I get as error 0RA-01981... Please help me in this
    SQL> select to_date('2009-03-31','yyyy-mm-dd') xc from dual ;
    
    XC
    ------------------------------
    31-MAR-09
    

    For your http://ora-01981.ora-code.com/ error

    SS

  • Need help getting started

    Hello

    I heard that Muse is very easy to make Web site. I downloaded the free version and I need help to get started.

    I want to do something like this: http://image.noelshack.com/fichiers/2013/50/1386717589-medal-of-honor-website-preview.png

    How to make tables?

    Blury will be made with paint.net as I did, or I have an option to do it automatically?

    How can I create animations? -> Language, connection and I want to add one thing to copyright at the bottom that you can open and is blury where it is.

    How to make a website, adapting to the different screen resolution and what I choose for the Web site resolution?

    Thanks for helping me.

    I tried alone, but I don't know how to add the link, I tried to make a table, but it wasn't like I wanted to...

    Hello

    Regarding the tables, check this suggestion

    http://forums.Adobe.com/message/5906843#5906843

    And regarding the resolution.

    http://forums.Adobe.com/message/5902453#5902453

    As I understand it, you try to create a sensitive site. It is already added to the feature request, and Muse development team is already working on it.

    I hope this helps.

  • need help on filling data dynamically from list of choice while the page is loading

    Hi all

    I need to dynamically fill data in the picklist (drop-down list on the component) during the loading of the page itself, can you please a little help on this. I mean for the values of the component < f: selectItems > < af:selectOneChoice > must be filled dynamically, so that loading page. I will be grateful if you can provide examples of code.


    Thanks in advance



    Concerning
    Ashok E

    Hello

    the problem with your code is that it is not af:selectItem but f: selectItems


    *

    Frank

  • Need help to completely remove Adobe Application Manager.

    I just tried to update my Adobe Application Manager, but he told me that the installation has been broken, I went and uninstalled hoping that I could just download the installer again and reinstall.

    It did not work, and now the package install for Adobe Application Manager tried again to update and not to do a fresh install. It gives me the error that it could not initialize when I try.

    I guess the only thing now is to root parts of the registry for this there is no other trace left MAO on my PC.

    Running Windows 8.1 with Photoshop CC, CC Bridge and Lightroom 5.7 installed. As well as the Air and Flash Player.

    HO, Kevin,.

    You can follow the article: use of the cleaning tool CC to resolve installation problems. CC, CS3 - CS6 which helps you completely remove Adobe Application manager on your computer.

    Let us know if you still face problems with this.

    Thank you

    Yann Arora

  • New cascade, I need help getting started to learn

    Hi all

    I'm new to Cascade, so confusing to start.  I have a question that needs your help to clarify:

    1. I create a control in QML Editor, because of the ease to make and listen to samples, give the id to it. So how do the handle in C++ code?

    2. are there any resource tutorial for some basic needs, such as: collect the text box data, display data, etc...

    There are a lot of samples, but I need an explanation of principle so that I can get contact with the sample easier.

    Enjoy your share!

    1. https://developer.blackberry.com/cascades/documentation/dev/integrating_cpp_qml/index.html

    2. https://developer.blackberry.com/cascades/documentation/dev/javascript/index.html

  • Need help on displaying data

    Hello Experts,

    I create custom pages 3.

    Page1 (requester Details) - employee details (to be completed by the user) who raise a request

    Page2 (expense lines) - employee details for shown who had entered the first page (region1) and

    Noire2 - Advanced table to add lines and enter the details of expenses where more than one line is possible.

    Page 3 (Summary page) - Details of the employee in the first page + lines of expenditure in the second page + the textual data (approvers list) which is readonly text.

    Submit page3.

    All together in the area of train MultiPage.

    Could you please help how to create page3 (summary page) which the expenditure lines to display page 2?

    Things that will help me to design the page.

    Thanks in advance,

    Suman

    Keep AOS (Application Module) even for pages that allows you to view the details of the first page and the second page on the last page (just displaying VO instance. no need to refresh). So you can easily submit it to the end.

    Kind regards

    Stephanie.

Maybe you are looking for

  • Ultra widescreen LG

    Before the Sierra macOS. My screen is very good. But after update all icon and letter when extra-large and looks burry. Please advice what I can do to solve the problem.

  • scanning black and white but colored wrong scan OK

    OfficeJet Pro 8600 more Copies n & B Standalone are very low. Color copies are excellent. B & W scans on my computer appear almost not. Color scans are excellent. Any ideas?

  • Unable to connect my bluetooth with Z510

    Hello I have ideapad Z510 with me. I recently bought the Sony SBH20 stereo headphones. I tried to connect it with my camera. He got paired up, but it is not a connection. I googled and got to know it is matter of some A2DP drivers. Trying to find the

  • Liquid duo E380 Bluetooth problem

    Hello I have a new E380 and good bluetooth icon says ignition does not turn green on the display (it remains grey) I have problems to connect what either get it You think it is a defective phone, or I'm doing something completely stupid!

  • Start with different user name

    I use Windows XP, also using a HP hard drive and monitor. As of late, I've noticed that when I go out for a minute or two, a window pops up saying connect, but then I see a 'Switch User'. I don't remember since when I got the HP. How can I get rid of