I have 3 classes: MainActivity,DrawView and SecondActivity. MainActivity just use DrawView to draw something on the screen. How can I start SecondActivity when i touch the screen on an Bitmap, I know where is the bitmap(in the code). The onTouchEvent function from DrawView class.
@Override
public boolean onTouchEvent(final MotionEvent ev) {
switch (ev.getAction()) {
case MotionEvent.ACTION_DOWN: {
float posX = ev.getX();
float posY = ev.getY();
if(play.touched(posX, posY)==true){
} else {
}
return true;
}
}
return false;
}
The function play.touched(posX,posY) return a boolean value(I made a class that handel the position of the Bitmap). How can I start Second Activity from here?
if(play.touched(posX, posY)){
Intent intent = new Intent(getContext(), SecondActivity.class);
((Activity)getContext()).startActivity(intent);
} else {
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With