PhoneFactory.getDefaultPhone must be called from Looper thread

写了一个设置、显示本机号码的小工具(A small tool displays and settings my phone number),详见”Android设置显示本机号码“。照着Settings写的,运行时,遇到了:
1487 AndroidRuntime E Caused by: java.lang.RuntimeException: PhoneFactory.getDefaultPhone must be called from Looper thread
1487 AndroidRuntime E at
1487 AndroidRuntime E ... 24 more



在AndroidManifest.xml 把android:sharedUserId=”android.uid.system”也加上,问题解决。像CM的固件, 编译的时候,android.uid.system 是 Android 默认的公共签名。如果使用android.uid.system的apk签名不不一样,是不能装的,会报错:ERROR/PackageManager(81): Package org.lytsing.myphonenumber has no signatures that match those in shared user android.uid.system; ignoring!

当然,android手机第三方开发者不能用这个方法。网上还有其他一些解决办法,参看: 原理是通过AIDL及反射机制,使用隐藏API。

If you enjoyed this post, make sure you subscribe to my RSS feed!

3 Replies to “PhoneFactory.getDefaultPhone must be called from Looper thread”

  1. Hi, thanks for the hints. After following your steps, I can make the apk run on the emulator. But it cannot be installed on a real device. Could you show any light? Does it mean the device must be rooted? Thanks.

Leave a Reply to Alfred Cancel reply

Your email address will not be published. Required fields are marked *