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 7601913
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:16:43+00:00 2026-05-30T23:16:43+00:00

After following a beginners tutorial I ended up combining a bunch of lessons to

  • 0

After following a beginners tutorial I ended up combining a bunch of lessons to create a timer app which takes an amount of time and plays media once the time passes. The app worked perfectly…Yesterday. I don’t recall changing anything but when I tried to debug today the app would load to my phone, install, and crash. I get a load of error messages which I don’t understand:

02-28 15:12:58.864: E/AndroidRuntime(26257): FATAL EXCEPTION: main
02-28 15:12:58.864: E/AndroidRuntime(26257): java.lang.RuntimeException: Unable to start activity ComponentInfo{digital.clock.activity/digital.clock.activity.DigitalActivity}: java.lang.NullPointerException
02-28 15:12:58.864: E/AndroidRuntime(26257):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
02-28 15:12:58.864: E/AndroidRuntime(26257):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
02-28 15:12:58.864: E/AndroidRuntime(26257):    at android.app.ActivityThread.access$1500(ActivityThread.java:117)
02-28 15:12:58.864: E/AndroidRuntime(26257):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
02-28 15:12:58.864: E/AndroidRuntime(26257):    at android.os.Handler.dispatchMessage(Handler.java:99)
02-28 15:12:58.864: E/AndroidRuntime(26257):    at android.os.Looper.loop(Looper.java:130)
02-28 15:12:58.864: E/AndroidRuntime(26257):    at android.app.ActivityThread.main(ActivityThread.java:3683)
02-28 15:12:58.864: E/AndroidRuntime(26257):    at java.lang.reflect.Method.invokeNative(Native Method)
02-28 15:12:58.864: E/AndroidRuntime(26257):    at java.lang.reflect.Method.invoke(Method.java:507)
02-28 15:12:58.864: E/AndroidRuntime(26257):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
02-28 15:12:58.864: E/AndroidRuntime(26257):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
02-28 15:12:58.864: E/AndroidRuntime(26257):    at dalvik.system.NativeStart.main(Native Method)
02-28 15:12:58.864: E/AndroidRuntime(26257): Caused by: java.lang.NullPointerException
02-28 15:12:58.864: E/AndroidRuntime(26257):    at digital.clock.activity.DigitalActivity.onCreate(DigitalActivity.java:74)
02-28 15:12:58.864: E/AndroidRuntime(26257):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
02-28 15:12:58.864: E/AndroidRuntime(26257):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
02-28 15:12:58.864: E/AndroidRuntime(26257):    ... 11 more

And my main activity looks like so…

package digital.clock.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import android.app.AlarmManager;
import android.app.PendingIntent;
import java.util.ArrayList;
import android.gesture.Gesture;
import android.gesture.GestureLibraries;
import android.gesture.GestureLibrary;
import android.gesture.GestureOverlayView;
import android.gesture.Prediction;
import android.gesture.GestureOverlayView.OnGesturePerformedListener;


public class DigitalActivity extends Activity 
{

private GestureLibrary gLib;

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

    gLib = GestureLibraries.fromRawResource(this, R.raw.gestures);
    if (!gLib.load())
    {
        Toast.makeText(this, "Could not load Gesture Library", Toast.LENGTH_LONG).show();
        finish();
    }

    GestureOverlayView gestures = (GestureOverlayView) findViewById(R.id.gestures);



    final OnGesturePerformedListener handleGestureListener = new OnGesturePerformedListener() 
    {
        @Override
        public void onGesturePerformed(GestureOverlayView gestureView, Gesture gesture) 
        {

            ArrayList<Prediction> predictions = gLib.recognize(gesture);

            // one prediction needed
            if (predictions.size() > 0) 
            {
                Prediction prediction = predictions.get(0);
                // checking prediction
                if (prediction.score > 1.0) 
                {
                    // and action
                    timerAlert2();
                }
            }

        }
    };

    gestures.addOnGesturePerformedListener(handleGestureListener);





    //Create button and do something with intents...
    Button Activity2 = (Button) findViewById(R.id.Button01);
    Activity2.setOnClickListener(new View.OnClickListener()
    {
        public void onClick (View view)
        {
            Intent replyIntent = new Intent();
            setResult(RESULT_OK, replyIntent);
            finish();
        }
    });

    Button startTimer = (Button) findViewById(R.id.startTimer);
    startTimer.setOnClickListener(new View.OnClickListener()
    {
        public void onClick (View view)
        {
            timerAlert(view);
        }
    });

    Button stopAlarm = (Button) findViewById(R.id.stopAlarm);
    stopAlarm.setOnClickListener(new View.OnClickListener()
    {
        public void onClick (View view)
        {
            stopService(new Intent(getBaseContext(), MediaPlayerService.class));
        }
    });
}




public void timerAlert (View view)
{

    //Declare the EditText object
    EditText textField = (EditText) findViewById(R.id.timeInSeconds);

    //Get user-entered number and convert to string

    int i = Integer.parseInt(textField.getText().toString());

    //Declare intent object
    Intent timerIntent = new Intent(this, TimerBroadcastReceiver.class);

    //Create PendingIntent and set parameters (context, code, intent object to use, constants)
    PendingIntent myPendingIntent = PendingIntent.getBroadcast(this.getApplicationContext(), 0, timerIntent, 0);

    //Create AlarmManager and assign it the ALARM_SERVICE
    AlarmManager myAlarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);

    //set AlarmManager parameters (type, TriggerTime, Operation)
    //RTC_WAKEUP will wake up the phone for the alarm, RTC will activate the alarm next time the phone wakes
    myAlarmManager.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + (i * 1000), myPendingIntent);

    Toast.makeText(this, "Alarm is set for " + i + " seconds!", Toast.LENGTH_LONG).show();
}

public void timerAlert2 ()
{
    int i = 5;

    //Declare intent object
    Intent timerIntent = new Intent(this, TimerBroadcastReceiver.class);

    //Create PendingIntent and set parameters (context, code, intent object to use, constants)
    PendingIntent myPendingIntent = PendingIntent.getBroadcast(this.getApplicationContext(), 0, timerIntent, 0);

    //Create AlarmManager and assign it the ALARM_SERVICE
    AlarmManager myAlarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);

    //set AlarmManager parameters (type, TriggerTime, Operation)
    //RTC_WAKEUP will wake up the phone for the alarm, RTC will activate the alarm next time the phone wakes
    myAlarmManager.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + (i * 60000), myPendingIntent);

    Toast.makeText(this, "Alarm is set for " + i + " minutes!", Toast.LENGTH_LONG).show();
}

}
  • 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-30T23:16:45+00:00Added an answer on May 30, 2026 at 11:16 pm

    Seems like it isn’t finding your button: (it crashes on the line that tries to access the button you instantiated in line 73: Button01).

    Search your project, it should have a sub-directory called res and in it there should be a file named main.xml. In it you should find an element

     <Button
        android:id="@+id/button01"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button" />
    

    You should verify if your project includes this file and has that line in it. If you still have the problem, clean your project, that should correct it.

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

Sidebar

Related Questions

After following this tutorial to setup an EC2 instance for a Django app, I
After following this MVC 4 tutorial series I was trying some of the stuff
After following the steps outline in this Fluent NHibernate tutorial I am stuck on
After following the great advice given in a thread about service beans I have
After following these steps: http://developers.facebook.com/docs/mobile/android/build/ I find that everything goes well, but when I
I am trying to make a JQGrid for a simple table. After following through
I have a text file having words that i need to validate. After following
I need an event/events that will do the following: After user selects text/DOM element,
What are the consequences, (if any) not calling the conn.logoff() method after the following
After running the following SQL statements, you will see that, MySQL has automatically created

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.