Look at the logcat output. When an android app crashes it writes a log
message with the reason.
On Mar 23, 2014 2:47 PM, "Francesco Cembrola" <[email protected]>
wrote:

>
> Hi everybody,
> I am new to the forum.
> I have written a small app that uses two buttons to turn ON and OFF two
> LEDs.
> It compiles with no errors.
> The console says it was installed on my tablet correctly...but then it
> crashes when run.
>
> Can someone take a look at the code below and help me, please?
> By the way I am new to Java and android!
>
> Regards
>
> Francesco cembrola
>
> =========================================================
>
> package com.example.timobot;
>
> import ioio.lib.api.DigitalOutput;
> import ioio.lib.api.exception.ConnectionLostException;
> import ioio.lib.util.BaseIOIOLooper;
> import ioio.lib.util.IOIOLooper;
> import ioio.lib.util.android.IOIOActivity;
> import android.os.Bundle;
> import android.view.MotionEvent;
> import android.view.View;
> import android.view.View.OnTouchListener;
> import android.widget.Button;
>
>
> public abstract class MainActivity extends IOIOActivity implements
> OnTouchListener {
>
>     private final int Left_Pin = 6;
>     private final int Right_Pin = 3;
>     boolean LeftTurnState=false;
>     boolean RightTurnState=false;
>     private Button LEFT_Button,RIGHT_Button;
>
>     @Override
>     public void onCreate(Bundle savedInstanceState) {
>         super.onCreate(savedInstanceState);
>         setContentView(R.layout.activity_main);
>
>         LEFT_Button = (Button) findViewById(R.id.LEFT);
>         LEFT_Button.setOnTouchListener(this);
>
>         RIGHT_Button = (Button) findViewById(R.id.RIGHT);
>         RIGHT_Button.setOnTouchListener(this);
>         }
>
>         class Looper extends BaseIOIOLooper {
>           public    DigitalOutput LeftTurn;
>          public    DigitalOutput RightTurn;
>
>
>          @Override
>          protected void setup() throws ConnectionLostException {
>             LeftTurn = ioio_.openDigitalOutput(Left_Pin, false);
>             RightTurn = ioio_.openDigitalOutput(Right_Pin, false);
>             }
>
> @Override
> public void loop() throws ConnectionLostException {
>
>             LeftTurn.write(LeftTurnState);
>             RightTurn.write(RightTurnState);
>
>
>             try {
>                 Thread.sleep(100);
>                 }catch (InterruptedException e) {
>             }
>
>         }
>     }
> protected IOIOLooper createIOIOLooper(){
>     return new Looper();
>
> }
>     @Override
>     public boolean onTouch(View arg0, MotionEvent arg1) {
>
>         switch (arg0.getId())
>         {
>
>         case R.id.LEFT:
>             {
>
>             if(arg1.getAction()==MotionEvent.ACTION_DOWN)
>                 {
>              LeftTurnState=true;
>
>                 }
>             if (arg1.getAction()==MotionEvent.ACTION_UP)
>                {
>                 LeftTurnState=false;
>
>                }
>
>         }
>         break;
>
>         case R.id.RIGHT:
>          {
>             if(arg1.getAction()==MotionEvent.ACTION_DOWN)
>              {
>                 RightTurnState=true;
>
>              }
>             if (arg1.getAction()==MotionEvent.ACTION_UP)
>              {
>                 RightTurnState=false;
>
>             }
>             break;
>
>         }
>
>         }
>         return false;
>
> }
>
>     }
>
>
>
>
>
> --
> 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 http://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 http://groups.google.com/group/ioio-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to