I am currently modifying an existing app code. I want to call a function to this class file when the mShakeImage.start() occurs.
How can I call the function inside CallScreen to SingleEventView?

CallScreen

```
*/
package com.st.BlueMS.demos.AccEvent;

import android.Manifest;

import android.content.Intent;

import android.content.pm.PackageManager;

import android.net.Uri;

import android.support.v4.app.ActivityCompat;

import android.support.v4.content.ContextCompat;

import android.support.v7.app.AppCompatActivity;

public class CallScreen extends AppCompatActivity{

protected void CallingFunction() {

    final int REQUEST_PHONE_CALL = 1;

        Intent callIntent = new Intent(Intent.ACTION_CALL);

        callIntent.setData(Uri.parse("tel: 991"));

        if (ContextCompat.checkSelfPermission(CallScreen.this, 
  Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {

            ActivityCompat.requestPermissions(CallScreen.this, new String[]{Manifest.permission.CALL_PHONE}, REQUEST_PHONE_CALL);

        } else {

           startActivity(callIntent);
        }

    }
}

```

SingleEventView

```
public class SingleEventView extends LinearLayout implements EventView {

    public SingleEventView(Context context) {
        super(context);
        init(context);
    }

    public SingleEventView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context);
    }

    public SingleEventView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init(context);
    }

    @TargetApi(Build.VERSION_CODES.LOLLIPOP)
    public SingleEventView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
        init(context);
    }

    private @DrawableRes int mCurrentIconId;
    private ImageView mEventIcon;
    private TextView mEventText;
    private RepeatAnimator mShakeImage;
    private FeatureAccelerationEvent.DetectableEvent mCurrentDetectEvent = FeatureAccelerationEvent.DetectableEvent.NONE;
    /**
     * string were write the number of steps
     */
    private String mStepCountTextFormat;

    private void changeIcon(@DrawableRes int icon){
        if(icon==mCurrentIconId)
            return;
        mEventIcon.setImageResource(icon);
        mCurrentIconId=icon;
    }

    private void init(Context context){
        inflate(context, R.layout.view_acc_event_single,this);
        mEventIcon = findViewById(R.id.accEvent_singleEventIcon);
        mEventText = findViewById(R.id.accEvent_singleEventLabel);
        AnimatorSet shakeImage = (AnimatorSet) AnimatorInflater.loadAnimator(context,
                R.animator.shake);

        mShakeImage = new RepeatAnimator(shakeImage, 5);
        mShakeImage.setTarget(mEventIcon);

        mStepCountTextFormat = getResources().getString(R.string.stepCounterStringFormat);
    }

    @Override
    public void enableEvent(Node.Type type, FeatureAccelerationEvent.DetectableEvent eventType){
        mCurrentDetectEvent = eventType;
        changeIcon( EventIconUtil.getDefaultIcon(eventType));
        mEventText.setText(null);
    }

    private void changeOrientationIcon(@AccelerationEvent int event) {
        @DrawableRes int newIcon = EventIconUtil.getEventIcon(event);
        if (newIcon != mCurrentIconId) {
            changeIcon(newIcon);
        } else {
            mShakeImage.start();
            Context context = getContext();
            new AlertDialog.Builder(context)
                    .setTitle("Alert")
                    .setMessage("This is an alert")
                    .setNegativeButton("OK", null)
                    .show();

        }

    }

    @Override
    public void displayEvent(@AccelerationEvent int event, int data) {
        if(mCurrentDetectEvent == FeatureAccelerationEvent.DetectableEvent.ORIENTATION &&
                FeatureAccelerationEvent.hasOrientationEvent(event)) {
            changeOrientationIcon(event);
        }else {
            mShakeImage.start();
            Context context = getContext();
            new AlertDialog.Builder(context)
                    .setTitle("Alert")
                    .setMessage("This is an alert")
                    .setNegativeButton("OK", null)
                    .show();
            Intent intent = new Intent(getApplicationContext(), CallScreen.class);

        }

        if(mCurrentDetectEvent == 
                   FeatureAccelerationEvent.DetectableEvent.PEDOMETER &&``
                   event==FeatureAccelerationEvent.PEDOMETER && data>=0){

               mEventText.setText(String.format(mStepCountTextFormat,data));
        }
    }

    /**
     * store the current status of the view, if is transparent or not
     * @return object where we store the internal state
     */
    @Override
    public Parcelable onSaveInstanceState() {
        //begin boilerplate code that allows parent classes to save state
        Parcelable superState = super.onSaveInstanceState();

        return new SingleEventView.SavedState(superState,mCurrentIconId);
    }//onSaveInstanceState

    /**
     * restore the previous state of the view -> if it is transparent or not
     * @param state object where we have stored the data
     */
    @Override
    public void onRestoreInstanceState(Parcelable state) {
        //begin boilerplate code so parent classes can restore state
        if(!(state instanceof SingleEventView.SavedState)) {
            super.onRestoreInstanceState(state);
            return;
        }
        SingleEventView.SavedState ss = (SingleEventView.SavedState)state;
        super.onRestoreInstanceState(ss.getSuperState());
        //end

        changeIcon(ss.getIcon());

    }//onRestoreInstanceState

    /**
     * class used for store the internal state
     * see http://stackoverflow.com/questions/3542333/how-to-prevent-custom-views-from-losing-state-across-screen-orientation-changes
     *
     */
    public class SavedState extends BaseSavedState {
        private @DrawableRes int mIconId;

        SavedState(Parcelable superState,@DrawableRes int iconId) {
            super(superState);
            mIconId=iconId;
        }

        private SavedState(Parcel in) {
            super(in);
            this.mIconId = in.readInt();
        }

        @DrawableRes int getIcon(){
            return mIconId;
        }

        @Override
        public void writeToParcel(Parcel out, int flags) {
            super.writeToParcel(out, flags);
            out.writeInt(mIconId);
        }

        //required field that makes Parcelables from a Parcel
        public final Parcelable.Creator<SingleEventView.SavedState> CREATOR =
                new Parcelable.Creator<SingleEventView.SavedState>() {
                    public SingleEventView.SavedState createFromParcel(Parcel in) {
                        return new SingleEventView.SavedState(in);
                    }
                    public SingleEventView.SavedState[] newArray(int size) {
                        return new SingleEventView.SavedState[size];
                    }
                };
    }//SaveState

}

```

IMPORTANT PART TO ADD THE CALLING FUNCTION

```
@Override
public void displayEvent(@AccelerationEvent int event, int data) {
    if(mCurrentDetectEvent == FeatureAccelerationEvent.DetectableEvent.ORIENTATION &&
            FeatureAccelerationEvent.hasOrientationEvent(event)) {
        changeOrientationIcon(event);
    }else {
        mShakeImage.start();
        Context context = getContext();
        new AlertDialog.Builder(context)
                .setTitle("Alert")
                .setMessage("This is an alert")
                .setNegativeButton("OK", null)
                .show();
        Intent intent = new Intent(getApplicationContext(), CallScreen.class);

```

**EDIT**

I was able to call the function from callscreen to singleeventview.
But now once the calling function is executed, it does not go back to singleeventview.
How do I achieve this?

**LATEST CALLSCREEN CODE**

public class CallScreen extends AppCompatActivity{

@SuppressLint("MissingPermission")

@Override

protected void onStart() {

```
super.onStart();

final int REQUEST_PHONE_CALL = 1;

Intent callIntent = new Intent(Intent.ACTION_CALL);

callIntent.setData(Uri.parse("tel: 991"));

//----------------------check for permission before placing the call-----
if (ContextCompat.checkSelfPermission(CallScreen.this, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {

    ActivityCompat.requestPermissions(CallScreen.this, new String[]{Manifest.permission.CALL_PHONE}, REQUEST_PHONE_CALL);
} else {
    //------------places the call-----------------------------------------------
    startActivity(callIntent);
}

```

}

}

**LATEST SINGLEEVENTVIEW CODE**

@Override

```
public void displayEvent(@AccelerationEvent int event, int data) {

   if(mCurrentDetectEvent ==FeatureAccelerationEvent.DetectableEvent.FREE_FALL)

    {
        mShakeImage.start();

        Context context = getContext();

        //-----------test for position of shake image--------------------
        new AlertDialog.Builder(context)

                .setTitle("Alert")

                .setMessage("This is an alert")

                .show();

        //---------------call function from CallScreen()-----------------
        Intent intent = new Intent(context.getApplicationContext(), CallScreen.class);

        context.startActivity(intent);

    }

```