在我的LogCat中,当调试我的应用程序时,我经常得到:
E/TelephonyManager(5382): Hidden constructor called more than once per process!
我一直在谷歌周围搜索,虽然我注意到其他提到的错误(在其他日志中),但我无法确定这是什么意思。
这个错误是什么?为什么我得到它?它的意义是什么?
这是来自Android的源代码:
/* **提供有关电话服务的资料*设备。应用程序可以使用该类中的方法来*确定电话服务和州,以及访问一些*用户信息的类型。申请也可在接收电话状态变化通知的监听器。*
你不直接实例化这个类;相反,你会取回对实例的引用*{@链接android.content.Context#getSystemService* Context.getSystemService (Context.TELEPHONY_SERVICE)}。*
*请注意,访问某些电话信息是* permission-protected。您的应用程序无法访问受保护的对象*信息,除非它具有声明的适当权限*它的manifest文件。在应用权限的地方,会在*您访问受保护信息的方法。*/
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调用构造函数。
是否有多个实例:
telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
或代码中的类似内容?这可能会导致错误。
编辑:如果这不是你的代码引起的消息,那么它的程序运行与PID 5382我认为。