RichTextField truncation of text or ellipsis

Hi I'm new to dev Java of BB and I'm trying to truncate the text to a non-focusable RichTextField. Is this possible?

I tried without success to the following:

...RichTextField _myRTF = new RichTextField(my_text, off, attrs, fonts, (DrawStyle.ELLIPSIS |
  RichTextField.FIELD_LEFT |
  RichTextField.NON_FOCUSABLE |
  RichTextField.NO_NEWLINE)) { ... };...

I also tried to use Labelfield.ELLIPSIS with no luck. This works for LabelField, but I use RichTextField because I'm using different font styles.

I ended up using LabelField with LabelField.ELLIPSIS, overiding the paint method and setting the police in there.

Tags: BlackBerry Developers

Similar Questions

  • Truncation of text instead of packing...

    I might be willing to something that is not technically possible, but I thought I'd ask anyway.

    I'm looking for a text truncator that will calculate how much room is on a line of text, and if text exceeds the horizontal space allotted, she cuts it and adds a «...» "at the ennd.

    Of course, because an OOOO and a line with iiii raise significantly different amounts of horizontal space, simply go with a fixed number of characters is not a viable solution. It should almost be a width in pixels.

    Is it feasible at all?

    I'm open to solutions javascript/jquery and css.

    Try CSS text-overflow .

    Example:

    div {}

    Width: 100px;

    overflow: hidden;

    white-space: nowrap;

    -o-text-overflow: ellipsis;

    -moz-text-overflow: ellipsis;

    -webkit-text-overflow: ellipsis;

    text-overflow: ellipsis;

    }

    --

    Kenneth Kawamoto

    http://www.materiaprima.co.UK/

  • Truncate the text after the first line in TextFlow

    I have a TextFlow object that is rendered in a Sprite with several lines.

    For a compact display, I now want to show only the first line, followed by 3 dots (...).

    I've not found a good approach up to now.

    There is a support for truncation.  It is limited to cases of use of label and requires the use of the TextLine factories.  There is no support for text editable with truncation.   Example below.

    Hope that helps,

    Richard

    /**
    ADOBE SYSTEMS INCORPORATED
    Copyright 2011 Adobe Systems Incorporated
    All Rights Reserved.

    NOTICE:  Adobe permits you to use, modify, and distribute this file
    in accordance with the terms of the Adobe license agreement
    accompanying it.  If you have received this file from a source
    other than Adobe, then your use, modification, or distribution
    of it requires the prior written permission of Adobe.
    */
    package
    {
        import flash.display.DisplayObject;
        import flash.display.Sprite;
        import flash.display.StageAlign;
        import flash.display.StageScaleMode;
        import flash.geom.Rectangle;
        import flash.text.StyleSheet;
        import flash.utils.ByteArray;
       
        import flashx.textLayout.container.ContainerController;
        import flashx.textLayout.conversion.TextConverter;
        import flashx.textLayout.elements.TextFlow;
        import flashx.textLayout.formats.TextLayoutFormat;
        import flashx.textLayout.factory.StringTextLineFactory;
        import flashx.textLayout.factory.TextFlowTextLineFactory;
        import flashx.textLayout.factory.TruncationOptions;
       
        [SWF(width="500", height="500")]
        public class Truncation extends Sprite
        {
           
            public function Truncation()
            {
                stage.align = StageAlign.TOP_LEFT;
                stage.scaleMode = StageScaleMode.NO_SCALE;
               
                // sample of truncation with the StringFactory
                var stringFactory:StringTextLineFactory = new StringTextLineFactory();
                var stringSprite:Sprite = new Sprite();
                stringSprite.x = 25; stringSprite.y = 25; addChild(stringSprite);
                // this bounds has no maximum height
                stringFactory.compositionBounds = new Rectangle(0,0,200,NaN);
                stringFactory.text = "This is an extremely long and overly verbose string of text that I would like to see trunctated.";
                // truncate after two lines
                stringFactory.truncationOptions = new TruncationOptions(TruncationOptions.HORIZONTAL_ELLIPSIS,2);
                stringFactory.createTextLines(function (obj:DisplayObject):void { stringSprite.addChild(obj); });
               
                // sample of truncation with the TextFlowTextLineFactory
                var flowFactory:TextFlowTextLineFactory = new TextFlowTextLineFactory();
                var flowSprite:Sprite = new Sprite();
                flowSprite.x = 25; flowSprite.y = 75; addChild(flowSprite);
                // this bounds has no maximum height
                flowFactory.compositionBounds = new Rectangle(0,0,200,NaN);
                // truncate after three lines with a big red ellipsis
                flowFactory.truncationOptions = new TruncationOptions(TruncationOptions.HORIZONTAL_ELLIPSIS,3,TextLayoutFormat.createTextLayoutFormat({ fontSize:24, lineHeight:0, color:0xff0000 }));
                flowFactory.createTextLines(function (obj:DisplayObject):void { flowSprite.addChild(obj); },TextConverter.importToFlow(Data.markup, TextConverter.TEXT_LAYOUT_FORMAT));
            }
        }
    }
    class Data
    {
        public static const markup:String = "" +
            "

    The following excerpt is from Ethan Brand by Nathaniel Hawthorne.

    " +
            "

    There are many such lime-kilns in that tract of country, for the purpose of burning the white marble which composes" +
            " a large part of the substance of the hills. Some of them, built years ago, and long deserted, with weeds growing in the vacant round of the interior, which is open to the sky," +
            " and grass and wild-flowers rooting themselves into the chinks of the stones, look already like relics of antiquity, and may yet be overspread with the lichens of centuries to come." +
            " Others, where the lime-burner still feeds his daily and nightlong fire, afford points of interest to the wanderer among the hills, who seats himself on a log of wood or a fragment " +
            "of marble, to hold a chat with the solitary man. It is a lonesome, and, when the character is inclined to thought, may be an intensely thoughtful occupation; as it proved in the case " +
            "of Ethan Brand, who had mused to such strange purpose, in days gone by, while the fire in this very kiln was burning.

    The man who now watched the fire was of a " +
            "different order, and troubled himself with no thoughts save the very few that were requisite to his business. At frequent intervals, he flung back the clashing weight of the iron door, " +
            "and, turning his face from the insufferable glare, thrust in huge logs of oak, or stirred the immense brands with a long pole. Within the furnace were seen the curling and riotous flames, " +
            "and the burning marble, almost molten with the intensity of heat; while without, the reflection of the fire quivered on the dark intricacy of the surrounding forest, and showed in the " +
            "foreground a bright and ruddy little picture of the hut, the spring beside its door, the athletic and coal-begrimed figure of the lime-burner, and the half-frightened child, shrinking " +
            "into the protection of his father's shadow. And when again the iron door was closed, then reappeared the tender light of the half-full moon, which vainly strove to trace out the " +
            "indistinct shapes of the neighboring mountains; and, in the upper sky, there was a flitting congregation of clouds, still faintly tinged with the rosy sunset, though thus far down " +
            "into the valley the sunshine had vanished long and long ago.

    ";
    }

  • [Q] text on ellipse

    Hello.

    I am doing a project for my friend and I want to "delivered" text to be upside, but still be on the way, ships 2nd I did it in the 'Text wrapped' tool for the text.

    In addition, it would be nice if the text of 'material' was in the 2nd direction.

    http://i.imgur.com/uwOKXOH.jpg

    You need to duplicate the layer and the path and the reversal at the global level by adjusting the alignemnt of text until it 'is', after which you edit the text on the two layers to maintain the illusion. You can also rotate the layer duplicated using free transform, but will still need to make some changes and formatting text.

    Mylenium

  • APEX 5 - Visual "truncates" data IR-region ("" text...: ' ") but the field must be available

    APEX 5

    Theme: 26. Productivity applications
    Interactive report region

    I have 1 long NUMBER 'Company profile' in my Interactive area.
    I need to see the following text: "this company has 1000 employees, but...". »

    But I need the IR research work on the text of this article.

    Is it possible Visual truncate the text to < my_text > | "...', but an intern can I do a search on all the data of this element"company profile "?

    Thank you

    user555867 wrote:

    Update your forum profile with a recognizable username instead of "user555867": Video tutorial how to change username available

    I have 1 long NUMBER 'Company profile' in my Interactive area.

    I need to see the following text: "this company has 1000 employees, but...". »

    But I need the IR research work on the text of this article.

    Is it possible Visual truncate the text to . "...', but an intern can I do a search on all the data of this element"company profile "?

    1 edit the column company profile IR, setting the property Expression of HTML

    #COMPANY_PROFILE#

    where "COMPANY_PROFILE" is the alias for the column.

    2 Add the following style sheet to the IR CSS Inline property page:

    .profile-text {
      width: 19em;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    
  • Text field Forms 10 g (which doubles as a text editor) is text to be truncated.

    I have 2000 text field of characters on a form 10g which is one called 'comments '.
    You can enter in the field
    Or click the button next to the field and who calls EDIT_TEXTITEM forms;
    And opens the field as a text editor.

    GO_ITEM ('inventory_coding.COMMENTS');
    EDIT_TEXTITEM;

    The problem is:
    When we went to forms on the web application server 10g,
    The area is truncating the text background,
    And the text is remarkably low sitting on the ground,
    At the top of the text in the middle of the field.

    The field shows the first 30 characters of the top line of all that is in the editor.
    (the text in the Editor seems fine)

    Comment fields properties are:
    * police = Ariel 8 in the comment field is the same as other fields on the screen (ariel 8)
    If you increase the size of the font to ariel 8 to 10, the truncation increases.
    If you go the next police, ariel 7, it also truncates.
    * This is the same hauteur.188 as the rest of the fields on the form.
    * Page/justify was initially start and tried to justify in left and Center, both of truncation.
    * Multiline = yes
    * Wrapstyle = Word
    * I checked all the properties of the field coment and his call button.
    and I tried to change each property with no improvement.

    My goal is to decrease the space above the text in the comments field.
    Any ideas how can I manipulate the text in the field?
    Any suggestion is appreciated!

    Published by: Doug_Galayda on September 1, 2009 09:00

    The recangle is the newline character that is displayed if "Multiline" is set to no.

    Could you build a simple testform with a single item with multiple lines, assign Yes to?

  • Representative of the long text on label with 3 points

    Hello

    I have a label field that has a fixed layoutchild, which is relatively low for the content of the very long label...

    That part of the text that the label can contain is displayed alone... But I would like to add three points after the text to display for the user that there is always a part of the text that is not displayed...

    How can I achieve this?

    Hi sheeluwiki
    no need to add points because you're labelfield it automatically will come if you go the LabelField one = new LabelField ("some text", DrawStyle.ELLIPSIS).

    Use DrawStyle.ELLIPSIS style for your labelfield and check...

    Thank you

  • MYSQL text field appears correctly in Datagrid

    Hello

    I have a datagrid which gets its data from a webservice. The result is a text field in the mysql database which is something like this:

    Hello

    Some text here. Some more text.

    Thank you

    When that field is displayed in the DataGridColumn, only the first line is to say 'Hi', gets displayed. I tried to set the property wordwrap and variableRowHeight true. but dsnt work. I even put the ItemEditor to mx.controls.Text and mx.controls.TextArea. Still nothing. No idea how to get all the text to display in the column.

    Still one thing to note is that I have the itemRenderer for this datagrid to mx.controls.Label column, so that if the textcontent is greater than the content of the cell, datagrid will truncate the text and display a ToolTip. So, I expected the ToolTip is displayed in this case, but it dsnt.

    I confirmed that the webservice response contains the paragraph of text... so it only means that things are going wrong during the time display...

    Help, please!

    Because you used the label as driving force of rendering you will get a... When the width of text > width of the label. But here you don't him have not found because the width of the text could not be greater than the width of the label. The text in question here is a multiline text. Label will show only single line. And the longer your data line is also less than the width of the label. That's why not. You can check this by giving a long line of your data and it will show a... and the ToolTip (if you use the label as itemrenderer).

    The default item converter will display the multiline text. So no need to specify any itemRenderer.You may have variableRowHeight set to true. There is no need to use the itemEditor to get what you are looking for. Yet one thing, an editor of point will only work if you set the property editable DataGrid and the itemeditor usage column is set to true.

    Hope that I have answered your question

  • Truncate the Label control

    Hello!

    How can I trucate a label control?

    I put it is with 100% in a tray of pixels about 112 and what he does in Flex 4, is jumping on the next line.

    How can I get cut and Add «...» "in the end, based on the width of the container, please?

    1 value to explicit linebreak and maxDisplayedLines

    To disable this automatic packaging machine, set lineBreak style to "explicit" . Then the lines are broken where only the text contains an explicit line break and the ends of the lines stretching from past the edge right is cut off.

    If you have more text that you have room to display it, the Label may truncate the text for you.   Tronquantes text, replace text with an indicator of truncation such as «...» ».   See inherited properties maxDisplayedLines and isTruncated .

    - http://help.adobe.com/en_US/FlashPlatform//reference/actionscript/3/spark/components/Label .html

  • JDE 4.7 CAP question?

    I I have a problem with a JDE 4.7 code signing application and it seems that it is apparent to the CAP JDE 4.7 compiler.

    Basically I modified HelloWorld.java that comes with JDE 4.7 examples to add an API call control (see below for more details). Then, I compiled and generated the jad and jar files. After that, I used the following command line to generate the .cso, .csl and .cod files JDE 4.2 and 4.7 JDE environment respectively with exactly the same file jad and jar file:

    CAP import = net_rim_api.jar = HelloWorldSigning = HelloWorldSigning.jad HelloWorldSigning.jar jad codname

    However, I found that HelloWorldSigning.cso generated under 4.7 environment does not have entry "52525400 = RIM Runtime API" in it compared with that generated under environment 4.2. (The HelloWorldSigning.csl files are the same). As a result, the signed HelloWorldSigning.cod less 4.7 will get "attempts to access a secure API" error loading on devices of the storm, then the HelloWorldSigning.cod signed under 4.2 has no problem. If I manually fix the file cso by adding the missing entry under 4.7, it will solve the problem.

    No idea what's wrong with him?

    PS:

    HelloWorldSigning.csl under 4.2 and 4.7 as follows:

    52525400 = RIM API implementation

    HelloWorldSigning.cso less than 4.7:

    33000000 = RIMAPPSA2
    52424200 = RIM Blackberry Apps API
    52434300 = RIM API Crypto - Certicom
    52434900 = RIM Crypto API - internal
    52435200 = RIM API Crypto - RIM

    HelloWorldSigning.cso minus 4.2:

    3000000 = RIMAPPSA2
    52434300 = RIM API Crypto - Certicom
    52434900 = RIM Crypto API - internal
    52435200 = RIM API Crypto - RIM
    52525400 = RIM API implementation
    52424200 = RIM Blackberry Apps API

    Code source HelloWorld.java:
    /**
    *
    * HelloWorld.java
    * The sentinal sample!
    *
    * Copyright © 1998-2008 Research In Motion Ltd.
    *
    * Note: For simplicity, this sample application cannot operate
    * resource bundles and resource strings.  However, it is STRONGLY recommended
    * that make application developers use available location functions
    in the development platform BlackBerry to ensure uniform application
    * experience in a variety of languages and geographies.  For more information
    * on the location of your application, please refer to the BlackBerry Java Development
    * Environment Development Guide associated with this version.
    */

    package com.rim.samples.device.helloworlddemo;

    Import net.rim.device.api.notification.NotificationsConstants;
    Import net.rim.device.api.notification.NotificationsManager;
    Import net.rim.device.api.ui.UiApplication;
    Import net.rim.device.api.ui.container.MainScreen;
    Import net.rim.device.api.ui.Field;
    Import net.rim.device.api.ui.component.Dialog;
    Import net.rim.device.api.ui.component.LabelField;
    Import net.rim.device.api.ui.component.RichTextField;

    /*
    * BlackBerry applications that provide a user interface must extend
    * UiApplication.
    */
    class HelloWorldDemo extends UiApplication
    {
    /**
    * Entry point for application.
    */
    event object public final static = new Object() {}
    public String toString() {}
    return to "sing";
    }
    };
    Public Shared Sub main (String [] args)
    {
    Create a new instance of the application.
    NotificationsManager.registerSource (0x8f8c19257ffbb06fL, event, NotificationsConstants.CASUAL);
    PAP HelloWorldDemo = new HelloWorldDemo();
           
    To apply to enter the event thread and the beginning of message processing,
    We invoke the enterEventDispatcher() method.
    theApp.enterEventDispatcher ();
    }

    /**
    *

    The default constructor. All RIM user interface components creates and runs a push of the
    screen of the application root in the user interface stack.
    */
    HelloWorldDemo() private
    {
    Push the instance main screen user interface for rendering stack.
    pushScreen (new HelloWorldScreen());
    }
    }

    /**
    Create a new screen that covers the screen, which offers default standard
    * BlackBerry applications behavior.
    */
    / * package * final class HelloWorldScreen extends screen
    {

    /**
    * Manufacturer HelloWorldScreen.
    */
    HelloWorldScreen()
    {
    Add a field to the title area of the screen. We use a simple LabelField
    here. the SELECTION option truncates the text of the label with «...» "If the text
    It is too long for the space available.
    LabelField title = new LabelField ("Hello World Demo", LabelField.ELLIPSIS |) LabelField.USE_ALL_WIDTH);
    setTitle (title);

    Add a text field read-only (RichTextField) on the screen.  The RichTextField
    is active by default.  In this case, we provide a style to make the field
    non-focusable.
    Add (new RichTextField ("Hello World!", Field.NON_FOCUSABLE));
    }

    /**
    * Show a dialog box to the user with "Goodbye!" when the application
    * is closed.
    *
    * @see net.rim.device.api.ui.Screen #close)
    */
    public void close()
    {
    Display a farewell message before closing the application.
    Dialog.Alert ("Goodbye!");
    System.Exit (0);
           
    Super.Close ();
    }
    }

    Mark Merci for the quick reply.

    I have added the work around my build script, it seems to works fine.

  • Using DrawTextParam in a LabelField

    The problem I have is that I need an ellipsis at the beginning of the text.

    I have a method that creates a LabelField, it displays a path to a file. The file must have the end of the file visible.

    That's why I need ellipsis at the beginning so that the user can see the end of the path. I looked around and came across DrawTextParam. One of the fields is exactly what I need (TRUNCATE_WITH_ELLIPSIS_AT_START) but I can't find any style/method that accepts it.

    Is there a way I can use it on a field? Perferably LabelField but if something else accept it so I can change my code.

    Scratch what I just said. I did not read the documentation on this topic. If you use the SELECTION with TRUNCATE_BEGINNING field it truncates the text and add the points of suspension at the front of the text. Thanks Rajat_10Sep.

  • Screens, backgrounds and Bitmaps

    I'm still struglling with graphs and screens.  I thought that I understood.

    I want to start by creating a new main screen, put the back on the ground in the dark, and then add a manager of vertical field with buttons custom on top of the background.  Finally, I would like to

    change the background while the program is runing

    Add a new screen and vertical field as a popup screen for my custom button Manager

    But I need to cross first in the background.

    ADDING A VERTICAL MANAGER WITH CUSTOM BUTTONS FIELD WORK, change the background doesn't work. Note that I caught the code directly from the knowledge base.  The background command make it past the build, but does nothing, I still have a white screen and the transparent parts of my selected button show in the background of the theme.

    Screen is the screen or basic framework of the user of RIM interface class.
    Display display = new MainScreen();
           
    Add a field to the title area of the screen. The SELECTION option truncates the text of the label with «...» "If the text was
    too long for the space available.
    mainScreen.setTitle (new LabelField ("Test", LabelField.ELLIPSIS |)) LabelField.USE_ALL_WIDTH));

    Background bg = BackgroundFactory.createSolidBackground (Color.BLACK);
    mainScreen.setBackground (bg);

    Add a vertical field Manager with fields of sample custom button.

    VFM VerticalFieldManager = new VerticalFieldManager();
                
    ONOFF button
    OnOff = new CustomButtonField (CustomButtonField.ONOFF, Field.FOCUSABLE);
    onoff.setChangeListener (this);
    VFM. Add (onoff);

    mainScreen.add (vfm);

    We have completed the construction of our user interface objects. Push the screen
    instance on the stack in the user interface for rendering.
    pushScreen (mainScreen);

    Any help is appreciated!

    Thank you REXDOUG.

    I was beginning to think it was a focus problem.  But what through me is that blue takes a place defined by the scope of the key.  Blue focus on the Blackberry keyboard seems to extend to the surrounding graphics. Finally, I would like to add the blue ring to my buttons, but the Blue will have to overlap the surrounding buttons, does not stop at the scope.  The focus indicator, I'm getting is THEREFORE unacceptable.

    No worries if.  Time for me to BONE up on the focus and the blue (theme controlled) focus indicator.  If I can't understand, I will beg for help again.

    I have this will mark it as resolved when I have a moment.

  • HorizontalFieldManager in a DialogFieldManager

    Hi I'm trying to place a HorizontalFieldManager that contains a BasicEditField and a ButtonField in a DialogFieldManager.  When I run the code below in the HorizontalFieldManager fields do not appear.

    DialogFieldManager dfm = (DialogFieldManager)getDelegate();
             dfm.setIcon(new BitmapField(Bitmap.getPredefinedBitmap(Bitmap.QUESTION)));
             dfm.setMessage(new RichTextField("Select a text file for results"));
    
            _txtfilename = new BasicEditField() {
                protected void paint(Graphics g) {
                    if (getTextLength() == 0) {
                        g.setColor(0x00a0a0a0);
                        g.drawText("Enter Text File Name", 0, 0);
                    }
                    g.setColor(0xF5F5F5);
                    super.paint(g);
                }
            };
            _txtfilename.setBorder(BorderFactory.createSimpleBorder(new XYEdges(2, 2, 2, 2), 0xF5F5F5));
            _btnOK = new ButtonField();
             HorizontalFieldManager hfm = new HorizontalFieldManager()
             {
                 public void sublayout(int width, int height) {
                      int xpos = 0;
                      int ypos = 0;
                      Field field = getField(0);
    
                      setPositionChild(field, xpos, ypos);
                      layoutChild(field, 280, 50);
    
                      Field field1 = getField(1);
    
                      setPositionChild(field1, xpos+20, ypos+80);
                      layoutChild(field1, 100, 50);
    
                      setPosition(150, 220);
                      setExtent(width, height);
                 }
             };
             hfm.add(_txtfilename);
             hfm.add(_btnOK);
             dfm.add(hfm);
    
            _olf = new ObjectListField();
            dfm.addCustomField(_olf);
            updateList(path);
            _txtfilename.setFocus();
    

    Any help would be greatly appreciated.

    Thank you.

    According to my interpretation of the Javadocs, instead:

    DFM. Add (HFM);

    you will need

    dfm.addCustomField (hfm);

    have you tried that?
    :

  • How to detect an incomming SMS? -HELPPPP

    Hello everyone,

    This is my first post in this forum. So far, it has helped me a lot. But since a few days, I have had a problem. I want to detect an incomming SMS. I read some post and I found a few pieces of codes that are interesting. But, I failed to do so.

    Here are a few links I've read:

    -http://www.j2mepolish.org/javadoc/j2me/de/enough/polish/messaging/MessageListener.html

    -http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800451/800563/What _...

    - http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800451/800563/How_To _...

    - http://supportforums.blackberry.com/t5/Java-Development/notifyIncomingMessage-only-called-for-first-...

    - http://supportforums.blackberry.com/t5/Java-Development/How-to-listen-to-incoming-sms-message-only/m...

    I will stop here with links.

    Now, here is my code:

    /*
     * hw.java
     *
     * © , 2003-2008
     * Confidential and proprietary.
     */
    
    import java.util.*;
    import java.lang.*;
    import java.io.*;
    import java.io.IOException;
    import javax.microedition.location.*;
    import javax.microedition.io.*;
    import javax.microedition.io.file.*;
    import javax.microedition.pim.*;
    import javax.wireless.messaging.*;
    import net.rim.device.api.io.*;
    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.device.api.i18n.*;
    import net.rim.blackberry.api.invoke.*;
    
    /**
     *
     */
    class hw extends UiApplication {
        public static void main(String[] args)
        {
            hw instance = new hw();
            instance.enterEventDispatcher();
        }
        public hw()
        {
            pushScreen(new SalutationScreen());
        }
    }
    
    class SalutationScreen extends MainScreen implements Runnable //, MessageListener
    {
        private Thread t;
        private MessageConnection _mc;
    
        public SalutationScreen()
        {
            super();
            LabelField applicationTitle =
                new LabelField("Hello World Title");
            setTitle(applicationTitle);
            RichTextField helloWorldTextField = new RichTextField("Hello World!");
            add(helloWorldTextField);
    
            t = new Thread(this);
            t.start();
    /*
            try {
                _mc = (MessageConnection)Connector.open("sms://:0");
                _mc.setMessageListener(this);
                helloWorldTextField = new RichTextField("setMessageListener : done");
                add(helloWorldTextField);
            }
            catch (IOException e) {
                helloWorldTextField = new RichTextField("erreur constructeur : " + e);
                add(helloWorldTextField);
            }
    */
        }
    
        public boolean onClose()
        {
            Dialog.alert("Bye World!");
            System.exit(0);
                    return true;
        }
    
        public void run()
        {
            try{
                DatagramConnection _dc = (DatagramConnection)Connector.open("sms://:0");
    
                for(;;)
                {
                    Datagram d = _dc.newDatagram(_dc.getMaximumLength());
                    _dc.receive(d);
                    byte[] bytes = d.getData();
                    String address = d.getAddress();
                    String msg = new String(bytes);
    
                    helloWorldTextField = new RichTextField("  Message text received : " + msg );
                    add(helloWorldTextField);
                }
            }
            catch(Exception e){}
    
    /* METHOD 2
            while(true)
            {
                try
                {
                    DatagramConnection _dc = (DatagramConnection)Connector.open("sms://");
                    Datagram d = _dc.newDatagram(_dc.getMaximumLength());
                    _dc.receive(d);
                    String address = new String(d.getAddress());
                    String msg = new String(d.getData()); 
    
                    helloWorldTextField = new RichTextField("Message received: " + msg + "\n" + address);
                    add(helloWorldTextField);
                    Alert.startVibrate(3000);
                }
                catch (IOException e)
                {
                        System.err.println(e.toString());
                }
            }
    */           
    
    /*  METHOD 3
            try {
                MessageConnection _mc = (MessageConnection)Connector.open("sms://:0");
    
                for(;;)
                {
                    Message m = _mc.receive();
                    String address = m.getAddress();
                    String msg = null;
                    if ( m instanceof TextMessage )
                    {
                        TextMessage tm = (TextMessage)m;
                        msg = tm.getPayloadText();
                    }
                    else if (m instanceof BinaryMessage) {
    
                        StringBuffer buf = new StringBuffer();
                        byte[] data = ((BinaryMessage) m).getPayloadData();
                        // convert Binary Data to Text
                        msg = new String(data, "UTF-8");
                    }
                    else
                        System.out.println("Invalid Message Format");
    
                    RichTextField helloWorldTextField = new RichTextField("Received SMS text from " + address + "\n" + msg);
                    add(helloWorldTextField);
                }
        }
        catch (IOException e)
        {
                System.err.println(e.toString());
        }
    */
        }
    
    /*  METHOD 4
            public void notifyIncomingMessage(MessageConnection conn) {
                RichTextField helloWorldTextField = new RichTextField("notifyIncomingMessage DEBUT");
                add(helloWorldTextField);                
    
                try {
                    Message m = conn.receive();
                    helloWorldTextField = new RichTextField("- Message recu");
                    add(helloWorldTextField);                
    
                    String address = m.getAddress();
                    String msg = null;
    
                    if ( m instanceof TextMessage )
                    {
                        TextMessage tm = (TextMessage)m;
                        msg = tm.getPayloadText();
                    }
                    else if (m instanceof BinaryMessage) {
                        StringBuffer buf = new StringBuffer();
                        byte[] data = ((BinaryMessage) m).getPayloadData();
    
                        // convert Binary Data to Text
                        msg = new String(data, "UTF-8");
                    }
                    else
                        System.out.println("Invalid Message Format");
    
                    helloWorldTextField = new RichTextField("- Message de : " + address + " // \""+ msg + "\"");
                    add(helloWorldTextField);
                }
                catch (IOException e) {
                    helloWorldTextField = new RichTextField("erreur _mc.receive : " + e);
                    add(helloWorldTextField);
                }
    
            }
    */
    
    /*  METHOD 5
            public void notifyIncomingMessage(MessageConnection messageConnection)
            {
                new Thread()
                {
                    MessageConnection conn;
                    Thread set(MessageConnection conn)
                    {
                        this.conn = conn;
                        return (this);
                    }
                    public void run()
                    {
                        try
                        {
                            Message m = conn.receive();
                            String msg = null;
    
                            if ( m instanceof TextMessage)
                            {
                                TextMessage tm = (TextMessage) m;
                                msg = tm.getPayloadText();
    
                                RichTextField helloWorldTextField = new RichTextField("- Message de : " + m.getAddress() + " // \""+ msg + "\"");
                                this.add(helloWorldTextField);
                            }
                        }
                        catch (Exception e)
                        {
                        }
                    }
                }.set(messageConnection).start();
            }
    */
    }
    

    In my code, I tested 5 methods. But, I think that all of them blocked the line where there is method of 'received() '.

    If there is someone who can help me find my problem, it's going to be great. (Or if there is someone who wants to send me a complete code that works, it will be better than the grand )

    Thank you for all the answers.

    I agree with you. It's better if I post a solution.

    I have re-written some other program that gets the phone number and the content of the incomming SMS.

    Here is my code

    public class smsReceived extends UiApplication
    {
        private LabelField _status;
        private DatagramConnection _dc;
    
        public static void main(String[] args)
        {
            new smsReceived().enterEventDispatcher();
        }
    
        public smsReceived()
        {
            super();
            waitASms();
       }
    
        public void waitASms()
        {
            try
            {
                _dc = (DatagramConnection)Connector.open("sms://");
                for(;;)
                {
                    Datagram d = _dc.newDatagram(_dc.getMaximumLength());
                    _dc.receive(d);
                    String address = new String(d.getAddress());
                    String msg = new String(d.getData());
                }
            }
            catch (IOException e)
            {
                System.err.println(e.toString());
            }
        }
    }
    

    In this code, the string 'address' is the phone number and the string 'msg' is the content.

    To view, please do another method with this channels.

    Next time.

  • Terms of Service dialog

    Dear Sir

    I wonder how to implement such terms of service screen has App World.

    I tried to make a class that extends the dialogue and build but how do I open it to start?

    I want to show if possible before the first screen is pushed.

    I have no problem to decide whether or not this is the first start of the application, this is already done.

    But I already have display problems of the dialog without a pushed screen application.

    And how close the application correctly if the user refuses?

    Best regards

    Bullety

    If you absolutely must push the TOS dialog box before the first screen of the application, you need to use pushModal() with the property 'GLOBAL '.

    I'd say ditch the dialog class and make your own TOS dialog using PopupScreen with a RichTextField for TOS text. You'll want to place two buttons 'Accept' and 'I refuse. "

    You provide a getResponse() (or other) method that returns the value of the key (such as 0 = Accetpt, 1 = decline). If the answer is the decline, you can call System.exit (0)

Maybe you are looking for

  • AT300 - question of battery charge

    I recently Bough an AT300 and so far am very happy with it. A big disappointment, however, that there don't seem to be able to charge through the USB port but only via the large proprietary connection. Is this good? If t is the way it is supposed to

  • Satellite Pro A120 SE-163: need a new AC adapter

    I tried to look in the manual the user & on the toshiba Web site (options & Accessories) but can't find anything that tells me the part/model number for parts spare/new ac adapter for Satellite Pro A120SE-163. Please can someone tell where I can get

  • Disks HARD IX4 - 200 d always running

    With an another IX4 - 200 d (no-cloud edition) my hard drives are running all the time, even if there is no activity! It is very noisy. Anyone knows how to fix? Thank you

  • Legend field size changes when the cursor moved legend

    So weird, I don't even thought it, but here it is: In VI attached, I have legends of the parcel next graphics, if I can put checkboxes next to them for the turning on or off the channel display.  In the third, I need to include the sliders, but when

  • Latitude e7470, BitLocker, Windows 7

    We just bought a new e7470 of Latitude. We installed Windows 7 Enterprise. TPM is enabled in the BIOS with the default settings. Windows 7 is installed instead of the UEFI Legacy mode. BIOS version is 1.9.4, the latest version. I noticed this is TPM