You don't need two activities. It doesn't make sense, since two activities
are not typically alive at the same time. Merge them into one activity that
does both the GUI and the IOIO stuff (from inside a IOIOLooper, which can
be an inner class or a regular one, define in a separate file).

On Wed, Mar 16, 2016 at 3:30 AM, Ilan Tal <[email protected]> wrote:

> In order that my connection to ioio will not die upon the phone screen 
> shutting down, I put most of the ioio activity into a separate class.
> I have a text view and a button defined on the main activity.
>
> I defined a constructor in IoioTerbiumActivity which takes as an input the 
> MainActivity object. That way I can control the text view and button from 
> inside IoioTerbiumActivity.
>
> When I tried the project, it showed the text view and the button but clearly 
> did not start my ioio class.
> It clearly doesn't make sense to create the class and then call startActivity 
> with a new intent. If I just call startActivity, how do I bring across the 
> parent class?
> If I use the my1 from the constructor, what is the proper way to start the 
> activity?
>
> public class MainActivity extends AppCompatActivity {
>    TextView timerView;
>    int runState = 0;
>
>    @Override
>    protected void onCreate(Bundle savedInstanceState) {
>       super.onCreate(savedInstanceState);
>       setContentView(R.layout.activity_main);
>       timerView = (TextView) findViewById(R.id.timerView);
>       Button b = (Button) findViewById(R.id.startBut);
>       b.setOnClickListener(new View.OnClickListener() {
>          @Override
>          public void onClick(View v) {
>             String txtTmp = getString(R.string.start_lab);
>             Button b = (Button) v;
>             switch (runState) {
>                case 0:
>                case 1:
>                   txtTmp = getString(R.string.stop_lab);
>                   runState++;
>                   break;
>
>                case 2:
>                   runState++;
>                   break;
>
>                default:
>                   runState = 0;
>                   break;
>             }
>             b.setText(txtTmp);
>          }
>       });
> //    IoioTerbiumActivity my1 = new IoioTerbiumActivity(this);
> //    startActivity(new Intent(this,IoioTerbiumActivity.class));
>    }
> }
>
> --
> You received this message because you are subscribed to the Google Groups
> "ioio-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/ioio-users.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"ioio-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/ioio-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to