how to swipe between two activities like lockscreen?

351 Views Asked by At

I am developing a lockscreen and i want to swipe between two activities like we swipe the home screen. I searched everywhere but i did not find any perfect answer. I used the view pager but its not working on activities. Then i tried this:

public void change(){
    int1= new Intent(this,WheelActivity.class);
    startActivityForResult(int1,1000);
      overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_right);
    finish();
}
public void change1(){

    int1= new Intent(this,ImageActivity.class);
    startActivityForResult(int1,1000);
      overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);
    finish();
}

 @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {

        overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);

    }

 @Override
    public boolean onTouchEvent(MotionEvent me) {
        return gDetector.onTouchEvent(me);
    }

    @Override
    public boolean onDown(MotionEvent arg0) {
        // TODO Auto-generated method stub
        return false;
    }

    @Override
    public boolean onFling(MotionEvent start, MotionEvent finish, float xVelocity, float yVelocity) {
        if (start.getRawX() < finish.getRawX()) {
            change();
        } 
        if (start.getRawX() > finish.getRawX()) {
            change1();
        } 

        return true;
    }

    @Override
    public void onLongPress(MotionEvent arg0) {
        // TODO Auto-generated method stub

    }

    @Override
    public boolean onScroll(MotionEvent arg0, MotionEvent arg1, float arg2,
            float arg3) {
        // TODO Auto-generated method stub
        return false;
    }

    @Override
    public void onShowPress(MotionEvent arg0) {
        // TODO Auto-generated method stub

    }

    @Override
    public boolean onSingleTapUp(MotionEvent arg0) {
        // TODO Auto-generated method stub
        return false;
    }

But the problem is that its not so smooth like home screen swipe or any other lockscreen. Please help me out of this problem. Thanks in advance.

0

There are 0 best solutions below