interface cannot be cast (ClassCastException: AlarmReceiver cannot be cast to AlarmReceiver$OnAlarmOver)
<p>I created a alarm and I hope when alarm is stop can set a String to TextView in MainActivity so I try to use interface but it's get error :</p>

<blockquote>
  <p>Caused by: java.lang.ClassCastException: AlarmReceiver cannot be cast to AlarmReceiver$OnAlarmOver</p>
</blockquote>

<p>AlarmReceiver.java</p>

<pre><code>public class AlarmReceiver extends BroadcastReceiver {
  public AlarmReceiver() {
  }

  @Override
  public void onReceive(Context context, Intent intent) {

    ...

    OnAlarmOver onAlarmOver = (OnAlarmOver) context; //&lt;--error
    onAlarmOver.OnAlarmOverText("Alarm stop");        
  }

  public interface OnAlarmOver {
    public void OnAlarmOverText(String overText);
  }
}
</code></pre>

<p>MainActivity.java</p>

<pre><code>public class MainActivity extends AppCompatActivity implements AlarmReceiver.OnAlarmOver {

  ...

  public void OnAlarmOverText(String overText){
    alarm_text.setText(overText);
  }
}
</code></pre>

<p>My English is very poor, sorry.</p>