When i try to use the setOnClickListener to make Pepper say something or do an animation the aplication crashes. However if i try the same code the method onRobotFocusedGained it works fine.
I tried multiple ways, one of them was to create a method to make Pepper do an animation and then call the method inside the setOnClickListener like this:
private void doAnimation(QiContext qiContext){
// Create an animation object.
Animation myAnimation = AnimationBuilder.with(qiContext)
.withResources(R.raw.sniffing_b001)
.build();
// Build the action.
Animate animate = AnimateBuilder.with(qiContext)
.withAnimation(myAnimation)
.build();
animate.run();
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Register the RobotLifecycleCallbacks to this Activity.
QiSDK.register(this, this);
ImageButton button1= findViewById(R.id.button1);
button1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
doAnimation();
}
});