什么"隐藏的构造函数调用一次以上每个进程和QUOT;意味着? [英] What does "Hidden constructor called more than once per process" mean?

查看:111
本文介绍了什么"隐藏的构造函数调用一次以上每个进程和QUOT;意味着?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的LogCat中同时调试我的应用程序,我经常得到:

In my LogCat while debugging my app, I often get:

E/TelephonyManager(5382): Hidden constructor called more than once per process!

我一直在谷歌上搜索了一下周围,虽然我注意到其他提到的错误(在其他日志),我不能确定这是什么意思。

I've been Googling around a bit, and while I noticed other mentions of the error (in other logs), I cannot identify what it means.

那么,这是什么错误?为什么会出现呢?什么是它的意义是什么?

So what is this error? Why am I getting it? And what is its significance?

推荐答案

这是从Android源$ C ​​$ C:

This is from the Android source code:

/ **  *可使用有关电话服务上  * 装置。应用程序可以使用这个类中的方法  *确定电话服务和状态,以及访问一些  *类型的用户信息。应用程序也可以注册  *一个监听器,接收电话的状态变化的通知。  *

 *您不要直接实例化这个类;相反,您检索  *通过引用实例  * {@link android.content.Context#getSystemService  * Context.getSystemService(Context.TELEPHONY_SERVICE)}。  *

 *请注意,获得一些电话信息  *许可保护。您的应用程序无法访问受保护  *信息,除非它在声明的相应权限  *它的清单文件。当应用权限,他们注意到,在  *方法,通过它您可以访问受保护的信息。  * /

/** * Provides access to information about the telephony services on * the device. Applications can use the methods in this class to * determine telephony services and states, as well as to access some * types of subscriber information. Applications can also register * a listener to receive notification of telephony state changes. *

* You do not instantiate this class directly; instead, you retrieve * a reference to an instance through * {@link android.content.Context#getSystemService * Context.getSystemService(Context.TELEPHONY_SERVICE)}. *

* Note that access to some telephony information is * permission-protected. Your application cannot access the protected * information unless it has the appropriate permissions declared in * its manifest file. Where permissions apply, they are noted in the * the methods through which you access the protected information. */

public class TelephonyManager {

private static final String TAG = "TelephonyManager";

private static Context sContext;
private static ITelephonyRegistry sRegistry;

/** @hide */
public TelephonyManager(Context context) {
    context = context.getApplicationContext();
    if (sContext == null) {
        sContext = context;

        sRegistry = ITelephonyRegistry.Stub.asInterface(ServiceManager.getService(
                "telephony.registry"));
    } else if (sContext != context) {
        Log.e(TAG, "Hidden constructor called more than once per process!");
        Log.e(TAG, "Original: " + sContext.getPackageName() + ", new: " +
                context.getPackageName());
    }
}

在TelephonyManager似乎把隐藏的构造方法中调用一次以上过程!入日志,当你的应用程序调用构造函数不止一次,作为消息显示。构造函数是使用getSystemService按在构造的意见调用。

The TelephonyManager seems to put the "Hidden constructor called more than once per process!" into the Log when your application calls the constructor more than once, as the message suggests. The constructor is called using the getSystemService as per the comments on the constructor.

你有多个实例:

telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);

或你的code类似的东西?这可能可能会导致错误。

or something similar in your code? This could possibly be causing the error.

编辑:如果这不是你的code引起的消息,然后它的程序与PID 5382上运行,我认为

If it's not your code causing the message then it's the program running with PID 5382 I think.

这篇关于什么"隐藏的构造函数调用一次以上每个进程和QUOT;意味着?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆