Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6975937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:25:57+00:00 2026-05-27T17:25:57+00:00

12-27 16:57:11.711: E/AndroidRuntime(22081): Caused by: java.lang.ClassCastException: com.mygps.android.AlarmReceiver. This is one of my error in

  • 0

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

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

sample 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;
                            }
                    }
            }
    };

}

Main.xml:

<?xml version="1.0" encoding="utf-8"?>
<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">


    <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"/>

<LinearLayout
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:gravity="center_horizontal"
    android:padding="10dip">

    <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"/>

    <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"/>

</LinearLayout>

logfile.xml

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


    <EditText
        android:id="@+id/edit"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:hint="Enter log filename here." />

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T17:25:58+00:00Added an answer on May 27, 2026 at 5:25 pm

    Please post the xml layout file associated with this and the full logcat. My suggestion, altho this may not matter, is to stop using the ((Button)findViewById(R.id.logging_interval)) method of referring to your controls and just use a variable. I only say this because I have seen the error when android interprets this as an attempt to recast and freaks out

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I get this error when running my iPhone app 2009-12-05 21:32:06.711 iTour[7595:207] *** Terminating
I have some lines in a CSV file like this: 1000001234,Account Name,0,0,3,711.32,0,0,18,629.64,22,340.96,COD,20,000.00,Some string,Some string
Given this XML: <DocText> <WithQuads> <Page pageNumber=3> <Word> July <Quad> <P1 X=84 Y=711.25 />
Can anyone explain the algorithm for amplifying G.711 µ-law encoded audio?
I have several chunks of PCM audio (G.711) in my C++ application. I would
I've written this to try and log onto a forum (phpBB3). import urllib2, re
I'm walking through Adam Kinney's Blend tutorials ( http://visitmix.com/labs/rosetta/EyesOfBlend/ ) and I'm seeing some
I have a regex that looks like this ((1010xxx)?(\d{11}|\d{10}|\d{7})+) Basically I want it to
Currently I'm working with PIDinRootline . This works fine. [PIDinRootline=8,9] //do something [end] [PIDinRootline=6,7,11]
Can you advise a G.711 audio codec implementation in C/C++ ? I am going

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.