どのように機能するかを確認する必要があるため、アラームアプリをダウンロードします。GNU ライセンス。
しかし、私はそれを実行できません。(何か?) をクリックすると、次のエラーが表示されます。
08-03 14:40:26.154: E/AndroidRuntime(255): at com.codeskraps.talarkam.TalarkamActivity.onResume(TalarkamActivity.java:108)
コードの一部:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.d(TAG, "onCreate Started");
setContentView(R.layout.alarm_controller);
prefs = PreferenceManager.getDefaultSharedPreferences(this);
tpAlarm = (TimePicker) findViewById(R.id.tpAlarm);
chkSnooze = (CheckBox) findViewById(R.id.chkSnooze);
etxtSnoozeMin = (EditText) findViewById(R.id.etxtSnoozeMin);
Button button = (Button) findViewById(R.id.btnSetAlarm);
btnSetTone = (Button) findViewById(R.id.btnSetTone);
chkVolume = (CheckBox) findViewById(R.id.chkVolume);
skbVolume = (SeekBar) findViewById(R.id.skbVolume);
button.setOnClickListener(setAlarmListener);
btnSetTone.setOnClickListener(this);
}
protected void onResume() {
Log.d(TAG, "onResume");
super.onResume();
tpAlarm.setCurrentHour(prefs.getInt(M_HOUR, 0));
tpAlarm.setCurrentMinute(prefs.getInt(M_MINT, 0));
chkSnooze.setChecked(prefs.getBoolean(M_SNOOZE, false));
etxtSnoozeMin.setText(prefs.getString(SNOOZE_T, "0"));
chkVolume.setChecked(prefs.getBoolean(CHKVOLUME, false));
skbVolume.setProgress(prefs.getInt(SKBVOLUME, 0));
Uri alarmUri = Uri.parse(prefs.getString(TONE, null));
Ringtone ringtone = RingtoneManager.getRingtone(this, alarmUri);
if (ringtone != null) {
String name = ringtone.getTitle(this);
btnSetTone.setText(name);
} else
btnSetTone.setText(getString(R.string.btn_SetAlarmTone));
if (prefs.getBoolean(FIRST_LAUNCH, true)) {
Intent checkIntent = new Intent();
checkIntent.setAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA);
startActivityForResult(checkIntent, MY_DATA_CHECK_CODE);
SharedPreferences.Editor editor = prefs.edit();
editor.putBoolean(FIRST_LAUNCH, false);
editor.commit();
}
}
protected void onPause() {
Log.d(TAG, "onPause");
super.onPause();
SharedPreferences.Editor editor = prefs.edit();
editor.putInt(M_HOUR, tpAlarm.getCurrentHour());
editor.putInt(M_MINT, tpAlarm.getCurrentMinute());
editor.putBoolean(M_SNOOZE, chkSnooze.isChecked());
editor.putString(SNOOZE_T, etxtSnoozeMin.getText().toString());
editor.putBoolean(CHKVOLUME, chkVolume.isChecked());
editor.putInt(SKBVOLUME, skbVolume.getProgress());
editor.commit();
}
LogCat:
08-03 14:40:25.684: D/TalarkamActivity(255): onCreate Started
08-03 14:40:25.965: D/dalvikvm(255): GC freed 599 objects / 51056 bytes in 86ms
08-03 14:40:26.134: D/TalarkamActivity(255): onResume
08-03 14:40:26.144: D/AndroidRuntime(255): Shutting down VM
08-03 14:40:26.144: W/dalvikvm(255): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
08-03 14:40:26.144: E/AndroidRuntime(255): Uncaught handler: thread main exiting due to uncaught exception
08-03 14:40:26.154: E/AndroidRuntime(255): java.lang.RuntimeException: Unable to resume activity {com.codeskraps.talarkam/com.codeskraps.talarkam.TalarkamActivity}: java.lang.NullPointerException: uriString
08-03 14:40:26.154: E/AndroidRuntime(255): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2950)
08-03 14:40:26.154: E/AndroidRuntime(255): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2965)
08-03 14:40:26.154: E/AndroidRuntime(255): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2516)
08-03 14:40:26.154: E/AndroidRuntime(255): at android.app.ActivityThread.access$2200(ActivityThread.java:119)
08-03 14:40:26.154: E/AndroidRuntime(255): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
08-03 14:40:26.154: E/AndroidRuntime(255): at android.os.Handler.dispatchMessage(Handler.java:99)
08-03 14:40:26.154: E/AndroidRuntime(255): at android.os.Looper.loop(Looper.java:123)
08-03 14:40:26.154: E/AndroidRuntime(255): at android.app.ActivityThread.main(ActivityThread.java:4363)
08-03 14:40:26.154: E/AndroidRuntime(255): at java.lang.reflect.Method.invokeNative(Native Method)
08-03 14:40:26.154: E/AndroidRuntime(255): at java.lang.reflect.Method.invoke(Method.java:521)
08-03 14:40:26.154: E/AndroidRuntime(255): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
08-03 14:40:26.154: E/AndroidRuntime(255): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
08-03 14:40:26.154: E/AndroidRuntime(255): at dalvik.system.NativeStart.main(Native Method)
08-03 14:40:26.154: E/AndroidRuntime(255): Caused by: java.lang.NullPointerException: uriString
08-03 14:40:26.154: E/AndroidRuntime(255): at android.net.Uri$StringUri.<init>(Uri.java:420)
08-03 14:40:26.154: E/AndroidRuntime(255): at android.net.Uri$StringUri.<init>(Uri.java:410)
08-03 14:40:26.154: E/AndroidRuntime(255): at android.net.Uri.parse(Uri.java:382)
08-03 14:40:26.154: E/AndroidRuntime(255): at com.codeskraps.talarkam.TalarkamActivity.onResume(TalarkamActivity.java:108)
08-03 14:40:26.154: E/AndroidRuntime(255): at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1149)
08-03 14:40:26.154: E/AndroidRuntime(255): at android.app.Activity.performResume(Activity.java:3763)
08-03 14:40:26.154: E/AndroidRuntime(255): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2937)