getInstance() of StateMachine

42 views
Skip to first unread message

anop...@gmail.com

unread,
Dec 11, 2013, 5:51:20 AM12/11/13
to codenameone...@googlegroups.com
How get an instance of the currently used StateMachine in order to use it in the native code?
I just want to use showForm("Main", null); when a TargetListener will read the content of an NFC card.

Thank you!

Shai Almog

unread,
Dec 11, 2013, 11:35:28 AM12/11/13
to codenameone...@googlegroups.com, anop...@gmail.com
You will need to pass an instance to that code or keep a static reference to that.
There is no standard method to get it.

anop...@gmail.com

unread,
Dec 12, 2013, 11:06:39 AM12/12/13
to codenameone...@googlegroups.com, anop...@gmail.com
How can I do that?

There is no way that the following happens:

public static StateMachine getInstance(){
    return this;
}

Can you please provide me with the code?

Chen Fishbein

unread,
Dec 12, 2013, 11:36:11 AM12/12/13
to codenameone...@googlegroups.com, anop...@gmail.com
do this in your StateMachine:


public class StateMachine extends StateMachineBase {
    
    private static StateMachine instance;
    
    public StateMachine(String resFile) {
        super(resFile);
        instance = this;
    }
    
    public static StateMachine getInstance(){
        return instance;    
    }
    
...
Reply all
Reply to author
Forward
0 new messages