私はアプリ開発の最終段階にあり、今日、Galaxy Nexus(4.0.4を実行)は、「スリープ」から復帰したときにエラーメッセージをスローしました。電話は約1時間ほどアイドル状態でした。
残念ながら、正確なエラーメッセージを書き留めることはできませんでしたが、logcatから次のメッセージを取得することができました。
私のアプリには、電話のインテントを調べるBroadcastReceiverと、いくつかのContentObserverを登録するサービスがあります。アプリをテストしているときにエラーが表示されません。
誰かがlogcatからの以下のエラーを見て、私のアプリがそれらを引き起こした可能性があるかどうかを判断するのを手伝ってもらえますか?
2012-07-15 22:36:57.213 I 8661/ActivityManager: Start proc com.google.android.apps.uploader for broadcast com.google.android.apps.uploader/.ConnectivityBroadcastReceiver: pid=13497 uid=10035 gids={3003}
2012-07-15 22:36:57.221 I 13497/dalvikvm: Turning on JNI app bug workarounds for target SDK version 11...
2012-07-15 22:36:57.245 I 13497/ActivityThread: Pub com.google.android.apps.uploader: com.google.android.apps.uploader.UploadsContentProvider
2012-07-15 22:36:57.245 I 13497/ActivityThread: Pub com.google.photos.provider.Album: com.google.android.apps.uploader.clients.picasa.AlbumProvider
2012-07-15 22:36:57.245 D 13497/MediaUploader: UploaderApplication.onCreate
2012-07-15 22:36:57.260 D 13497/MediaUploader: nonWifiLimit=20971520, default=20971520
2012-07-15 22:36:57.260 I 13497/MediaUploader: No need to wake up
2012-07-15 22:36:57.268 D 9772/PicasaSyncManager: active network: NetworkInfo: type: WIFI[], state: CONNECTED/CONNECTED, reason: (unspecified), extra: (none), roaming: false, failover: false, isAvailable: true
2012-07-15 22:36:57.268 D 9772/PicasaSyncManager: background data: true
2012-07-15 22:36:57.268 I 8661/ActivityManager: No longer want com.android.voicedialer (pid 9435): hidden #16
2012-07-15 22:36:57.291 I 13103/DMApp: Constructor()
2012-07-15 22:36:57.291 I 13103/DMApp: onCreate......
2012-07-15 22:36:57.315 I 13103/SyncmlService: onBind
2012-07-15 22:36:57.370 I 13497/MediaUploader: No need to wake up
2012-07-15 22:36:57.370 D 9772/PicasaSyncManager: active network: NetworkInfo: type: WIFI[], state: CONNECTED/CONNECTED, reason: (unspecified), extra: (none), roaming: false, failover: false, isAvailable: true
2012-07-15 22:36:57.370 D 9772/PicasaSyncManager: background data: true
2012-07-15 22:36:57.682 D 8661/ConnectivityService: handleInetConditionHoldEnd: net=1, condition=100, published condition=100
2012-07-15 22:36:59.166 D 8861/IMSFW: ImsSMSInterface$1: EVENT_DEREGISTER_DONE_TIMEOUT occured
2012-07-15 22:36:59.174 D 8861/IMSFW: IIL: Instantiaing IIL
2012-07-15 22:36:59.174 D 8861/AndroidRuntime: Shutting down VM
2012-07-15 22:36:59.174 W 8861/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x40a4f1f8)
2012-07-15 22:36:59.182 E 8861/AndroidRuntime: FATAL EXCEPTION: main
android.content.ReceiverCallNotAllowedException: IntentReceiver components are not allowed to register to receive intents
at android.app.ReceiverRestrictedContext.registerReceiver(ContextImpl.java:116)
at android.app.ReceiverRestrictedContext.registerReceiver(ContextImpl.java:110)
at com.sec.android.internal.ims.sms.SMS3GPP.smsrelaylayer.SmsRLInterface.<init>(SmsRLInterface.java:126)
at com.sec.android.internal.ims.sms.SMS3GPP.smsrelaylayer.SmsRLInterface.getInstance(SmsRLInterface.java:86)
at com.sec.android.internal.ims.sms.SMS3GPP.smsrelaylayer.RLMessageQueue.<init>(RLMessageQueue.java:65)
at com.sec.android.internal.ims.sms.SMS3GPP.smsrelaylayer.RLMessageQueue.getInstance(RLMessageQueue.java:57)
at com.sec.android.internal.ims.sms.SmsImsDispatcher.<init>(SmsImsDispatcher.java:77)
at com.sec.android.internal.ims.sms.SmsImsDispatcher.getInstance(SmsImsDispatcher.java:85)
at com.sec.android.internal.ims.sms.ImsSMSInterface.postIMSRegStatus(ImsSMSInterface.java:811)
at com.sec.android.internal.ims.sms.ImsSMSInterface$1.handleMessage(ImsSMSInterface.java:287)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
2012-07-15 22:36:59.190 D 8861/IMSFW: IIL: Connected to '7467' socket
2012-07-15 22:36:59.190 E 8861/IIL: Uncaught exception
java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
at android.os.Handler.<init>(Handler.java:121)
at com.sec.android.internal.ims.sms.SmsImsDispatcher.<init>(SmsImsDispatcher.java:64)
at com.sec.android.internal.ims.sms.SmsImsDispatcher.getInstance(SmsImsDispatcher.java:85)
at com.sec.android.ims.IIL.notifySocketConnection(IIL.java:316)
at com.sec.android.ims.IIL.access$100(IIL.java:28)
at com.sec.android.ims.IIL$IILReceiver.run(IIL.java:381)
at java.lang.Thread.run(Thread.java:856)
編集
これがsに関連する私のコードのすべてですReceiver
。私は実際に電話することはありませんregisterReceiver
。確認するために、EclipseでFileSearchを実行してを探しましたregisterReceiver
。
これが私のマニフェストです:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.myproject" android:versionCode="1" android:versionName="1.0">
<uses-permission android:name="android.permission.READ_CONTACTS"></uses-permission>
<uses-permission android:name="android.permission.READ_PHONE_STATE"></uses-permission>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
<application android:icon="@drawable/ic_icon" android:label="@string/app_name" android:theme="@android:style/Theme.Light">
<activity android:name=".CallListActivity"
android:label="@string/app_name"
android:theme="@android:style/Theme.Light"
android:configChanges="orientation"
android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name="MyPhoneReceiver">
<intent-filter>
<action android:name="android.intent.action.PHONE_STATE" />
<action android:name="com.myproject.MY_ACTION" />
</intent-filter>
</receiver>
<service android:name=".MyService" />
</manifest>
これが私のサービスです:
public class MyService extends Service {
private static MyContentObserver mContentObserver;
private static ContactContentObserver mContactContentObserver;
private Context mCtx;
public int onStartCommand(Intent intent, int flags, int startId) {
try {
if(mContentObserver == null) {
mContentObserver = new MyContentObserver();
mCtx = this.getApplicationContext();
mCtx.getContentResolver().registerContentObserver(CallLog.Calls.CONTENT_URI, true, mContentObserver);
}
mCtx = this.getApplicationContext();
if(mContactContentObserver == null) {
mContactContentObserver = new ContactContentObserver();
this.getApplicationContext().getContentResolver().registerContentObserver(ContactsContract.Contacts.CONTENT_URI, true, mContactContentObserver);
}
}
catch (Exception e) {
}
return START_STICKY;
}
public IBinder onBind(Intent intent) {
// We don't provide binding, so return null
return null;
}
public void onPause() {
}
public void onDestroy() {
try {
if(mContentObserver != null)
this.getApplicationContext().getContentResolver().unregisterContentObserver(mContentObserver);
if(mContactContentObserver != null)
this.getApplicationContext().getContentResolver().unregisterContentObserver(mContactContentObserver);
super.onDestroy();
}
catch (Exception e) {
}
}
private class MyContentObserver extends ContentObserver {
public MyContentObserver() {
super(null);
}
@Override
public void onChange(boolean selfChange) {
try {
Intent intent = new Intent();
intent.setAction("com.myproject.MY_ACTION");
sendBroadcast(intent);
super.onChange(selfChange);
}
catch (Exception e) {
}
}
}
private class ContactContentObserver extends ContentObserver {
public ContactContentObserver() {
super(null);
}
@Override
public void onChange(boolean selfChange) {
super.onChange(selfChange);
try {
ContactUpdateTask updateContactsTask = new ContactUpdateTask(mCtx);
updateContactsTask.execute(null);
}
catch (Exception e) {
}
}
private class ContactUpdateTask extends AsyncTask<Void, Void, Void> {
private Context mCtx;
private ContactUpdateTask(Context _ctx) {
mCtx = _ctx;
}
protected Void doInBackground(Void... arg0) {
try {
// DB stuff
}
catch (Exception e) {
}
return null;
}
protected void onProgressUpdate(Void... arg0) {
switch (mType) {
}
}
protected void onPostExecute(Void arg0) {
publishProgress((Void)null);
}
}
}
}
これが私のBroadcastReceiverです:
public class MyPhoneReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
try {
Bundle extras = intent.getExtras();
if (extras != null) { // Intent == android.intent.action.PHONE_STATE
//DB stuff
if (something)
flag = false;
else
flag = true;
}
else if (flag){
try {
// DB Stuff
}
catch (Exception e) {
}
try {
// DB Stuff
}
catch (Exception e) {
}
Intent startActivity = new Intent();
startActivity.setClass(context, NewActivity.class );
startActivity.setAction(NewActivity.class.getName());
startActivity.setFlags(
Intent.FLAG_ACTIVITY_NEW_TASK |
Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
context.startActivity(startActivity);
}
}
catch (Exception e) {
}
}
}