Android Application Class Extension

When I was looking for a solution for receiving error reports from a remote device, like the flight test app on iOS, I found acra for Android devices here

In the basic setup, they said that we need to add some lines to the extends Application class .

In my project so far I have not created such a class, when I searched in this regard, I came up with several questions regarding the extends Application class .

I realized that they were talking about the Constant class, which contains global variables, I figured out the right way.

In my projects, I use to create a class called Constants , which contains some global variables , such as Strings, int, ArrayList , and I use this class to execute my api hits and json parsings . Can this class be used as extends Application .

If this is the same, in the link mentioned above, they said

 override the onCreate() method to add the ACRA init statement 

But so far I have not created the onCreate method in my Constant class. Am I doing the right thing?

+4
source share
1 answer

I would not try to combine your Constants class with this class. It is not worth the effort. Just create a new class that does what ACRA needs. Like this:

 public class MyApplication extends Application { @Override public void onCreate() { super.onCreate(); // do the ACRA init here } } 

Now you need to make sure that your MyApplication class will be used. So you need to add android:name to the <application> tag entry in your manifest like this:

 <application android:name="fully.qualified.package.name.MyApplication" 

Done.

+13
source

Source: https://habr.com/ru/post/1439087/


All Articles