扩展Android应用程序类 [英] Extending Android Application class
问题描述
当我正在寻找一个解决方案,从远程设备的错误报告,就像试飞的应用程序在iOS中,我发现了 ACRA
为Android设备<一HREF =HTTP://$c$c.google.com/p/acra/wiki/BasicSetup相对=nofollow>这里
When I was searching for a solution to get the error reports from remote device, just like the test flight app in iOS, I found the acra
for Android devices here
在基本建立了他们的说法,我们需要在添加一些线路延伸应用类
。
In the basic set up they have said we need to add some lines in extends Application class
.
在我的项目到目前为止,我还没有创建这样一个类,当我正在寻找SO关于这一点,我就过来了关于扩展应用程序类
几个问题。
In my project so far I have not created such a class, when I was searching in SO regarding this, I came over few questions regarding the extends Application class
.
据我所知,他们说其中包含了一个全局变量常量类,我已明白了正确的方式。
I understood that they are saying a Constant class which contains a global variables, have I understood the right way.
在我的项目中,我用它来创建一个名为常量
,其中包含一些全局变量
如类字符串,整型,ArrayList的
,我这个班我用做我的 API命中
和 JSON parsings
。难道这个类可以作为扩展应用程序
。
In my projects I use to create a class named as Constants
, which contains some global variables
such as Strings, int, ArrayList
and I this class I use to do my api hits
and json parsings
. Does this class can be used as extends Application
.
如果它是相同的,在上述连杆,它们都表示
If it is the same, in the above mentioned link, they have said
override the onCreate() method to add the ACRA init statement
但到目前为止,我还没有建立在我的常量类的onCreate
方法。我做了正确的事情?
But so far I have not created a onCreate
method in my Constant class. Am I doing the right thing?
推荐答案
我不会理会试图用此类合并的常量
类。这是不值得的。只要创建,做什么是必要的ACRA一个新的类。像这样的:
I wouldn't bother trying to merge your Constants
class with this class. It isn't worth the effort. Just create a new class that does what is necessary for ACRA. Like this:
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
// do the ACRA init here
}
}
现在,你需要确保你的所有MyApplication
类被使用。所以,你需要添加
Now you need to make sure that your MyApplication
class gets used. So you need to add
android:name="fully.qualified.package.name.MyApplication"
到&lt;应用&gt;以您的清单
标签输入
完成。
这篇关于扩展Android应用程序类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!