|
| 1 | +/* |
| 2 | + * Copyright (c) 2016 Kiall Mac Innes <kiall@macinnes.ie> |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 5 | + * not use this file except in compliance with the License. You may obtain |
| 6 | + * a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 12 | + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 13 | + * License for the specific language governing permissions and limitations |
| 14 | + * under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package ie.macinnes.tvheadend; |
| 18 | + |
| 19 | +import android.content.Context; |
| 20 | +import android.util.Log; |
| 21 | + |
| 22 | +import org.acra.ACRA; |
| 23 | +import org.acra.config.ACRAConfiguration; |
| 24 | +import org.acra.config.ACRAConfigurationException; |
| 25 | +import org.acra.config.ConfigurationBuilder; |
| 26 | +import org.acra.sender.HttpSender; |
| 27 | + |
| 28 | +public class Application extends android.app.Application { |
| 29 | + private static final String TAG = Application.class.getName(); |
| 30 | + |
| 31 | + @Override |
| 32 | + protected void attachBaseContext(Context base) { |
| 33 | + super.attachBaseContext(base); |
| 34 | + |
| 35 | + // Initialize ACRA crash reporting |
| 36 | + if (BuildConfig.ACRA_ENABLED) { |
| 37 | + Log.i(TAG, "Initializing ACRA"); |
| 38 | + try { |
| 39 | + final ACRAConfiguration config = new ConfigurationBuilder(this) |
| 40 | + .setHttpMethod(HttpSender.Method.PUT) |
| 41 | + .setReportType(HttpSender.Type.JSON) |
| 42 | + .setFormUri(BuildConfig.ACRA_REPORT_URI) |
| 43 | + .setLogcatArguments("-t", "500", "-v", "time", "*:I") |
| 44 | + .setAdditionalSharedPreferences(Constants.PREFERENCE_TVHEADEND) |
| 45 | + .setSharedPreferenceName(Constants.PREFERENCE_TVHEADEND) |
| 46 | + .setSharedPreferenceMode(Context.MODE_PRIVATE) |
| 47 | + .setBuildConfigClass(BuildConfig.class) |
| 48 | + .build(); |
| 49 | + ACRA.init(this, config); |
| 50 | + } catch (ACRAConfigurationException e) { |
| 51 | + Log.e(TAG, "Failed to init ACRA", e); |
| 52 | + } |
| 53 | + } |
| 54 | + } |
| 55 | +} |
0 commit comments