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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:28:04+00:00 2026-06-17T06:28:04+00:00

Hi i am making an app in which I am allowing user to add

  • 0

Hi i am making an app in which I am allowing user to add a reminder, but while i do click on Add New button getting Error – Unfortunately Reminderer has Stopped.

AddTaskActivity.java Code:

  public class AddTaskActivity extends Activity {
Task mTask;
Handler mHandler = new AddHandler();

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.add_task);

Button add = (Button) this.findViewById(R.id.submit);
add.setOnClickListener(new OnClickListener() {

    @Override
    public void onClick(View arg0) {
    GrammarParser parser = new GrammarParser();
    parser.setAndroidContext(AddTaskActivity.this);
    EditText text = (EditText) findViewById(R.id.add_task);
    String input = text.getText().toString();
    mTask = parser.parse(input);
    String output = mTask.toString();
    TextView log = (TextView) findViewById(R.id.log_cat);
    log.setText(output);
    }

});

Button save = (Button) findViewById(R.id.save);
save.setOnClickListener(new OnClickListener() {

    @Override
    public void onClick(View arg0) {
    if (mTask != null)
        DatabaseInterface.addTask(AddTaskActivity.this, mHandler,
            mTask);

    }

});

Button cancel = (Button) findViewById(R.id.cancel);
cancel.setOnClickListener(new OnClickListener() {

    @Override
    public void onClick(View arg0) {
    finish();

    }

});

}

add_task.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <EditText
        android:id="@+id/add_task"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="2"
        android:ems="10"
        android:inputType="text" >

        <requestFocus />
    </EditText>

    <Button
        android:id="@+id/submit"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="@string/add_new_task" />
</LinearLayout>

<TextView
    android:id="@+id/log_cat"
    android:layout_width="wrap_content"
    android:layout_height="0dip"
    android:layout_weight="1"
    android:text="@string/no_task"
    android:textAppearance="?android:attr/textAppearanceMedium" />

   <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <Button
        android:id="@+id/save"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="@string/save" />

    <Button
        android:id="@+id/cancel"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="@string/cancel" />
</LinearLayout>

</LinearLayout>

strings.xml:

<resources>

<string name="hello">Hello World, RemindererActivity!</string>
<string name="app_name">Reminderer</string>
<string name="hello_world">Hello world</string>
<string name="add_new_task">Add new</string>
<string name="submit">Submit</string>
<string name="no_task">Sample tasks:\n
    buy eggs\n
    buy eggs 8pm\n
    buy eggs Monday 9am\n
    buy eggs July 1\n
    buy eggs next Monday\n
    buy eggs 8pm repeats daily</string>
<string name="due_now">These task(s) are due now:</string>
<string name="dismiss">Dismiss</string>
<string name="snooze">Snooze</string>
<string name="save">Save</string>
<string name="cancel">Cancel</string>

Logcat Says:

    01-11 16:05:01.252: E/AndroidRuntime(943): FATAL EXCEPTION: main
01-11 16:05:01.252: E/AndroidRuntime(943): java.lang.NullPointerException
01-11 16:05:01.252: E/AndroidRuntime(943):  at com.frankandrobot.reminderer.AddTaskActivity$1.onClick(AddTaskActivity.java:39)
01-11 16:05:01.252: E/AndroidRuntime(943):  at android.view.View.performClick(View.java:4202)
01-11 16:05:01.252: E/AndroidRuntime(943):  at android.view.View$PerformClick.run(View.java:17340)
01-11 16:05:01.252: E/AndroidRuntime(943):  at android.os.Handler.handleCallback(Handler.java:725)
01-11 16:05:01.252: E/AndroidRuntime(943):  at android.os.Handler.dispatchMessage(Handler.java:92)
01-11 16:05:01.252: E/AndroidRuntime(943):  at android.os.Looper.loop(Looper.java:137)
01-11 16:05:01.252: E/AndroidRuntime(943):  at android.app.ActivityThread.main(ActivityThread.java:5039)
01-11 16:05:01.252: E/AndroidRuntime(943):  at java.lang.reflect.Method.invokeNative(Native Method)
01-11 16:05:01.252: E/AndroidRuntime(943):  at java.lang.reflect.Method.invoke(Method.java:511)
01-11 16:05:01.252: E/AndroidRuntime(943):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
01-11 16:05:01.252: E/AndroidRuntime(943):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
01-11 16:05:01.252: E/AndroidRuntime(943):  at dalvik.system.NativeStart.main(Native Method)
  • 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-06-17T06:28:05+00:00Added an answer on June 17, 2026 at 6:28 am

    It’s difficult to tell which line in onClick() is causing the NPE, as you haven’t provided line numbers. You need to perform more error checking in your code, and use assert() more often:

    @Override
    public void onClick(View arg0) {
        GrammarParser parser = new GrammarParser();
        parser.setAndroidContext(AddTaskActivity.this);
    
        EditText text = (EditText) findViewById(R.id.add_task);
        assert(text != null);
        String input = text.getText().toString();
        mTask = parser.parse(input);
        if (mTask != null) {
            String output = mTask.toString();
            TextView log = (TextView) findViewById(R.id.log_cat);
            assert(log != null);
            log.setText(output);
        }
        else {
            Log.e(TAG, "Failed to parse text");
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am making an app in which i am allowing user to fill the
i am making a app which takes photo on button click i have camera.java
I am making an app which will allow the user to click a picture
Hi i'm making an app which need to get user's gmail account contact list
I am Getting a weird problem. I am making an App which should run
I am making an app in which i am showing contacts to the user
I'm making an app which has a flow roughly as below: User starts on
I am making an app which has infinite scrolling while showing its results. I
Hello I am new to iPhone development and I am making an app which
I'm making an app with which the user can record sound and send it

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.