java.lang.ClassCastException
<p>12-27 16:57:11.711: E/AndroidRuntime(22081): Caused by: java.lang.ClassCastException: com.mygps.android.AlarmReceiver.</p>

<p>This is one of my error in logcat. What is the error and how can i solve it. </p>

<p>sample code:</p>

<pre><code>public class MainActivity extends Activity {
        private int currentIntervalChoice = 0;

    @Override
public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        setAppInfo();
        addButtonListeners();
        enableControls();
    }

        private void addButtonListeners() {
                ((Button)findViewById(R.id.start_logging)).setOnClickListener(btnClick);
                    ((Button)findViewById(R.id.logging_interval)).setOnClickListener(btnClick);
        }

        private void setAppInfo() {
                TextView txtInfo = (TextView)findViewById(R.id.app_info);

        txtInfo.setText(Html.fromHtml(getString(R.string.app_info)));

        Linkify.addLinks(txtInfo, Linkify.ALL);
        }

        private void toggleLogging(boolean isStart, int interval){
                AlarmManager manager =   (AlarmManager)getSystemService(Service.ALARM_SERVICE);
            PendingIntent loggerIntent = PendingIntent.getBroadcast(this, 0,new Intent(this,AlarmReceiver.class), 0);

            if(isStart){
                    manager.cancel(loggerIntent);

                    AppSettings.setServiceRunning(this, false);

                    AppLog.logString("Service Stopped.");
            }
            else{
                    setLogFileName();

                    long duration = interval * 60 * 1000;

                    manager.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,
                                    SystemClock.elapsedRealtime(), duration, loggerIntent);

                    AppSettings.setServiceRunning(this, true);

                    AppLog.logString("Service Started with interval " + interval + ", Logfile name: " + AppSettings.getLogFileName(this));
            }
    }

    private void enableControls(){
            boolean isServiceRunning = AppSettings.getServiceRunning(this);
            String buttonText = getString(R.string.start_logging);

            if(isServiceRunning){
                    buttonText = getString(R.string.stop_logging);

                    ((Button)findViewById(R.id.logging_interval)).setEnabled(false);
            }
            else{
                    ((Button)findViewById(R.id.logging_interval)).setEnabled(true);
            }

            ((Button)findViewById(R.id.start_logging)).setText(buttonText);
    }

    private void changeLoggingIntercal(){
            final AlertDialog.Builder builder = new AlertDialog.Builder(this);
            final String loggingIntervals[] = { "5 minutes", "15 minutes", "30 minutes", "1 hour" }; 

    builder.setTitle(getString(R.string.logging_interval));
    builder.setSingleChoiceItems(loggingIntervals, currentIntervalChoice, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                            currentIntervalChoice = which;

                            setLoggingInterval(currentIntervalChoice);

                            dialog.dismiss();
                    }
            });

    builder.show();
    }

    private void setLoggingInterval(int intervalChoice){
            int interval = 5;

            switch(intervalChoice){
                    case 0:         interval = 5;   break;
                    case 1:         interval = 15;  break;
                    case 2:         interval = 30;  break;
                    case 3:         interval = 60;  break;
                    default:        interval = 5;   break;
            }

            AppSettings.setLoggingInterval(this, interval);
    }

    public void setLogFileName(){
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            String dateString = sdf.format(new Date());
            String filename = "GPSLog." + dateString + ".kml";

            AppSettings.setLogFileName(this, filename);
    }

    private View.OnClickListener btnClick = new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                    switch(v.getId())
                    {
                            case R.id.start_logging:{
                                    toggleLogging(AppSettings.getServiceRunning(MainActivity.this), 
                                                              AppSettings.getLoggingInterval(MainActivity.this));

                                    enableControls();       

                                    break;
                            }
                            case R.id.logging_interval:{
                                    changeLoggingIntercal();

                                    break;
                            }
                    }
            }
    };
</code></pre>

<p>}</p>

<p>Main.xml:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dip"&gt;


    &lt;TextView  
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:gravity="center_horizontal"
    android:id="@+id/app_info"
    android:layout_weight="1.0"/&gt;

&lt;LinearLayout
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:gravity="center_horizontal"
    android:padding="10dip"&gt;

    &lt;Button
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:id="@+id/start_logging"
            android:text="@string/start_logging"
            android:layout_weight="1.0"/&gt;

    &lt;Button
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:id="@+id/logging_interval"
            android:text="@string/logging_interval"
            android:layout_weight="1.0"/&gt;

&lt;/LinearLayout&gt;
</code></pre>

<p></p>

<p>logfile.xml</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:padding="10dip"&gt;


    &lt;EditText
        android:id="@+id/edit"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:hint="Enter log filename here." /&gt;
</code></pre>

<p></p>
