android alarm not able to launch alarm activity

Posted by user965830 on Stack Overflow See other posts from Stack Overflow or by user965830
Published on 2012-06-25T14:24:57Z Indexed on 2012/06/28 9:16 UTC
Read the original article Hit count: 355

Filed under:
|
|

I am new to android programming and am trying to make this simple alarm app. I have my code written and it is compiled with no errors. The app runs in the emulator, that is the main activity asks the date and time, but when i click on the confirm button, it displays the message - "Unfortunately, Timer1 has stopped working."

The code for my main activity is as follows:

public void onClick(View v) {
    EditText date = (EditText) findViewById(R.id.editDate);
    EditText month = (EditText) findViewById(R.id.editMonth);
    EditText hour = (EditText) findViewById(R.id.editHour);
    EditText min = (EditText) findViewById(R.id.editMin);
    int dt = Integer.parseInt(date.getText().toString());
    int mon = Integer.parseInt(month.getText().toString());
    int hr = Integer.parseInt(hour.getText().toString());
    int mnt = Integer.parseInt(min.getText().toString());
    Intent myIntent = new Intent(MainActivity.this, AlarmActivity.class);
    pendingIntent = PendingIntent.getService(MainActivity.this, 0, myIntent, 0);
    AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
    Calendar calendar = Calendar.getInstance();
    calendar.set(Calendar.DATE, dt);
    calendar.set(Calendar.MONTH, mon);
    calendar.set(Calendar.HOUR, hr);
    calendar.set(Calendar.MINUTE, mnt);
    alarmManager.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), pendingIntent);
}

I do not understand what all the errors in logcat mean, so i am posting them:

06-25 16:03:32.175: I/Process(566): Sending signal. PID: 566 SIG: 9
06-25 16:03:53.775: I/dalvikvm(612): threadid=3: reacting to signal 3
06-25 16:03:54.046: I/dalvikvm(612): Wrote stack traces to '/data/anr/traces.txt'
06-25 16:03:54.255: I/dalvikvm(612): threadid=3: reacting to signal 3
06-25 16:03:54.305: I/dalvikvm(612): Wrote stack traces to '/data/anr/traces.txt'
06-25 16:03:54.735: I/dalvikvm(612): threadid=3: reacting to signal 3
06-25 16:03:54.785: I/dalvikvm(612): Wrote stack traces to '/data/anr/traces.txt'
06-25 16:03:54.925: D/gralloc_goldfish(612): Emulator without GPU emulation detected.
06-25 16:05:09.605: D/AndroidRuntime(612): Shutting down VM
06-25 16:05:09.605: W/dalvikvm(612): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
06-25 16:05:09.685: E/AndroidRuntime(612): FATAL EXCEPTION: main
06-25 16:05:09.685: E/AndroidRuntime(612): java.lang.NumberFormatException: Invalid int: "android.widget.EditText@41030b40"
06-25 16:05:09.685: E/AndroidRuntime(612):  at java.lang.Integer.invalidInt(Integer.java:138)
06-25 16:05:09.685: E/AndroidRuntime(612):  at java.lang.Integer.parse(Integer.java:375)
06-25 16:05:09.685: E/AndroidRuntime(612):  at java.lang.Integer.parseInt(Integer.java:366)
06-25 16:05:09.685: E/AndroidRuntime(612):  at java.lang.Integer.parseInt(Integer.java:332)
06-25 16:05:09.685: E/AndroidRuntime(612):  at com.kapymay.tversion1.MainActivity$1.onClick(MainActivity.java:34)
06-25 16:05:09.685: E/AndroidRuntime(612):  at android.view.View.performClick(View.java:3511)
06-25 16:05:09.685: E/AndroidRuntime(612):  at android.view.View$PerformClick.run(View.java:14105)
06-25 16:05:09.685: E/AndroidRuntime(612):  at android.os.Handler.handleCallback(Handler.java:605)
06-25 16:05:09.685: E/AndroidRuntime(612):  at android.os.Handler.dispatchMessage(Handler.java:92)
06-25 16:05:09.685: E/AndroidRuntime(612):  at android.os.Looper.loop(Looper.java:137)
06-25 16:05:09.685: E/AndroidRuntime(612):  at android.app.ActivityThread.main(ActivityThread.java:4424)
06-25 16:05:09.685: E/AndroidRuntime(612):  at java.lang.reflect.Method.invokeNative(Native Method)
06-25 16:05:09.685: E/AndroidRuntime(612):  at java.lang.reflect.Method.invoke(Method.java:511)
06-25 16:05:09.685: E/AndroidRuntime(612):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
06-25 16:05:09.685: E/AndroidRuntime(612):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
06-25 16:05:09.685: E/AndroidRuntime(612):  at dalvik.system.NativeStart.main(Native Method)
06-25 16:05:10.445: I/dalvikvm(612): threadid=3: reacting to signal 3
06-25 16:05:10.575: I/dalvikvm(612): Wrote stack traces to '/data/anr/traces.txt'

© Stack Overflow or respective owner

Related posts about android

Related posts about android-emulator