@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Bundle extras = getIntent().getExtras(); prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); if (prefs.getString("list_errorreporting", "ask").equalsIgnoreCase("always")) { Toast.makeText(this, getString(R.string.bugreport_dialogheader), Toast.LENGTH_LONG).show(); CustomExceptionHandler.sendEmail(extras.getString("bugReport"), this); finish(); } else if (prefs.getString("list_errorreporting", "ask").equalsIgnoreCase("ask")) { AlertDialog ad = new AlertDialog.Builder(this) .setTitle(getString(R.string.bugreport_dialogheader)) .setMessage(getString(R.string.options_bugreport_question)) .setPositiveButton( getString(R.string.options_bugreport_send), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { CustomExceptionHandler.sendEmail( extras.getString("bugReport"), ExceptionActivity.this); finish(); } }) .setNegativeButton( getString(R.string.options_bugreport_dontsend), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { finish(); return; } }) .create(); ad.setCancelable(false); ad.show(); } else { AlertDialog ad = new AlertDialog.Builder(this) .setTitle(getString(R.string.bugreport_dialogheader)) .setMessage(getString(R.string.options_bugreport_neversendmessage)) .setPositiveButton( getString(R.string.options_bugreport_ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { finish(); return; } }) .create(); ad.setCancelable(false); ad.show(); } }
/** On application creation. */ @Override public void onCreate() { super.onCreate(); sInstance = this; Connection.setContext(getApplicationContext()); // Error Reporter CustomExceptionHandler customExceptionHandler = CustomExceptionHandler.getInstance(); customExceptionHandler.Init(sInstance.getApplicationContext()); Thread.setDefaultUncaughtExceptionHandler(customExceptionHandler); SharedPreferences preferences = PrefSettings.getSharedPrefs(this); // Assign some default settings if necessary if (preferences.getString(PrefSettings.KEY_CHECK_URI, null) == null) { Editor editor = preferences.edit(); // Test Update Notifications // Some ridiculously fast polling, just to demonstrate it working... /* * editor.putBoolean(PrefSettings.KEY_ENABLED, true); editor.putLong(PrefSettings.KEY_PERIOD, 30 * 1000L); * editor.putLong(PrefSettings.KEY_CHECK_INTERVAL, 60 * 1000L); editor.putString(PrefSettings.KEY_CHECK_URI, * "http://ankidroid.googlecode.com/files/test_notifications.xml"); */ editor.putString( PrefSettings.KEY_CHECK_URI, "http://ankidroid.googlecode.com/files/last_release.xml"); // Create the folder "AnkiDroid", if not exists, where the decks // will be stored by default new File(getStorageDirectory() + "/AnkiDroid").mkdir(); // Put the base path in preferences pointing to the default // "AnkiDroid" folder editor.putString("deckPath", getStorageDirectory() + "/AnkiDroid"); // Using commit instead of apply even though we don't need a return value. // Reason: apply() not available on Android 1.5 editor.commit(); } // Reschedule the checks - we need to do this if the settings have // changed (as above) // It may also necessary in the case where an application has been // updated // Here for simplicity, we do it every time the application is launched Intent intent = new Intent(Veecheck.getRescheduleAction(this)); sendBroadcast(intent); }