Activity closed in middle of work and redirect it to previous activity

452 views Asked by At

I am created app for loan survey. In each survey 80 to 90 questions have been displayed. the questions is displayed one by one when he press next button. the views r created programatically and after submitting each question i have removed that views and create another views.

It works fine, but my problem is, when i am in 30 to 40 th question suddenly my activity closes and redirect to previous activity. Even it is not executing onPause method also. I dont know what is the problem. There is no app crash also. i don't no whether it caused due to memory error or any other. Please anyone suggest me how to solve it.

Thanks in advance

1

There are 1 answers

0
MysticMagicϡ On

Here is how close I could reach using combination of my answer of rotation of image around itself and this post of moving image in a circular path

//i is my ImageView here
// method to rotate globe
private void applyRotation(float start, float end) {

    //first animation for circular path
    final Animation rotation = new MyAnimation(i, 2000);
    rotation.setDuration(10000);
    rotation.setRepeatCount(0);

    //rotation of iamge
    final Animation rotation2 = new RotateAnimation(30, 360, i.getWidth()/2, i.getHeight()/2);
    rotation2.setFillAfter(true);
    rotation2.setRepeatCount(0);
    rotation2.setDuration(10000);
    rotation2.setInterpolator(new LinearInterpolator());

    //combine in a Set
    AnimationSet s = new AnimationSet(false);

    s.addAnimation(rotation);
    s.addAnimation(rotation2);
    i.startAnimation(s);
}

MyAnimation.java

package com.example.tempp;

import android.view.View;
import android.view.animation.Animation;
import android.view.animation.Transformation;

public class MyAnimation extends Animation {

    private View view;
    private float cx, cy;           // center x,y position of circular path
    private float prevX, prevY;     // previous x,y position of image during animation
    private float r;                // radius of circle


    /**
     * @param view - View that will be animated
     * @param r - radius of circular path
     */
    public MyAnimation(View view, float r){
        this.view = view;
        this.r = r;
    }

    @Override
    public boolean willChangeBounds() {
        return true;
    }

    @Override
    public void initialize(int width, int height, int parentWidth, int parentHeight) {
        // calculate position of image center
        int cxImage = width / 2;
        int cyImage = height / 2;
        cx = view.getLeft() + cxImage;
        cy = view.getTop() + cyImage;

        // set previous position to center
        prevX = cx;
        prevY = cy;
    }

    @Override
    protected void applyTransformation(float interpolatedTime, Transformation t) {
        if(interpolatedTime == 0){
            // I ran into some issue where interpolated would be
            return;
        }

        float angleDeg = (interpolatedTime * 360f + 90) % 360;
        float angleRad = (float) Math.toRadians(angleDeg);

        // r = radius, cx and cy = center point, a = angle (radians)
        float x = (float) (cx + r * Math.cos(angleRad));
        float y = (float) (cy + r * Math.sin(angleRad));


        float dx = prevX - x;
        float dy = prevY - y;

        prevX = x;
        prevY = y;

        t.getMatrix().setTranslate(dx, dy);
    }
}

Hope this helps.