Android API19 (KitKat) で com.android.internal.app.ChooserActivity まわりで leak !?

 

ブラウザからの「共有(share)」がひとつのアプリを固定して、選択できない状態に何回か遭遇。

正常であればこんなかんじのこの画面。

20131116-100144

この画面があたしの場合は表示されずFacebookに固定でインテントされるという現象。

そのときとったログはこれ。

I/ActivityManager(  774): START u0 {act=android.intent.action.CHOOSER flg=0x1 cmp=android/com.android.internal.app.ChooserActivity (has clip) (has extras)} from pid 24582
D/dalvikvm(  774): GC_FOR_ALLOC freed 4732K, 17% free 45594K/54824K, paused 61ms, total 62ms
W/InputMethodManagerService(  774): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@437ddc90 attribute=null, token = android.os.BinderProxy@430764a0
I/ActivityManager(  774): START u0 {act=android.intent.action.SEND typ=text/plain flg=0x3000001 cmp=com.facebook.katana/.activity.composer.ImplicitShareIntentHandler (has clip) (has extras)} from pid 24582
I/ActivityManager(  774): START u0 {cmp=com.facebook.katana/.activity.composer.ComposerActivity (has extras)} from pid 28268
W/l       (24582): [TiclService] Ticl being stopped: Client: com.google.protos.ipc.invalidation.ClientProtocol$ApplicationClientIdP@42641e80, \n\006\n\004\010\003\020\001\022\022\t;)\316\032<\326\326\246\021\250EC8\310\262\335\343\032\007\010\201\014\020\003\030\002, <RunState: STARTED>
E/ActivityThread(24582): Activity com.android.internal.app.ChooserActivity has leaked IntentReceiver com.android.internal.app.ResolverActivity$1@42df1160 that was originally registered here. Are you missing a call to unregisterReceiver()?
E/ActivityThread(24582): android.app.IntentReceiverLeaked: Activity com.android.internal.app.ChooserActivity has leaked IntentReceiver com.android.internal.app.ResolverActivity$1@42df1160 that was originally registered here. Are you missing a call to unregisterReceiver()?
E/ActivityThread(24582): 	at android.app.LoadedApk$ReceiverDispatcher.<init>(LoadedApk.java:805)
E/ActivityThread(24582): 	at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:606)
E/ActivityThread(24582): 	at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1430)
E/ActivityThread(24582): 	at android.app.ContextImpl.registerReceiver(ContextImpl.java:1410)
E/ActivityThread(24582): 	at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:474)
E/ActivityThread(24582): 	at com.android.internal.content.PackageMonitor.register(PackageMonitor.java:91)
E/ActivityThread(24582): 	at com.android.internal.content.PackageMonitor.register(PackageMonitor.java:69)
E/ActivityThread(24582): 	at com.android.internal.app.ResolverActivity.onCreate(ResolverActivity.java:139)
E/ActivityThread(24582): 	at com.android.internal.app.ChooserActivity.onCreate(ChooserActivity.java:53)
E/ActivityThread(24582): 	at android.app.Activity.performCreate(Activity.java:5243)
E/ActivityThread(24582): 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
E/ActivityThread(24582): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2140)
E/ActivityThread(24582): 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2226)
E/ActivityThread(24582): 	at android.app.ActivityThread.access$700(ActivityThread.java:135)
E/ActivityThread(24582): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1397)
E/ActivityThread(24582): 	at android.os.Handler.dispatchMessage(Handler.java:102)
E/ActivityThread(24582): 	at android.os.Looper.loop(Looper.java:137)
E/ActivityThread(24582): 	at android.app.ActivityThread.main(ActivityThread.java:4998)
E/ActivityThread(24582): 	at java.lang.reflect.Method.invokeNative(Native Method)
E/ActivityThread(24582): 	at java.lang.reflect.Method.invoke(Method.java:515)
E/ActivityThread(24582): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
E/ActivityThread(24582): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593)
E/ActivityThread(24582): 	at dalvik.system.NativeStart.main(Native Method)
I/ActivityManager(  774): Displayed com.facebook.katana/.activity.composer.ComposerActivity: +198ms (total +453ms)
W/IInputConnectionWrapper(24582): showStatusIcon on inactive InputConnection
D/dalvikvm( 1257): GC_FOR_ALLOC freed 2953K, 19% free 17201K/21156K, paused 13ms, total 13ms
I/dalvikvm-heap( 1257): Grow heap (frag case) to 19.741MB for 2986688-byte allocation
D/dalvikvm( 1257): GC_FOR_ALLOC freed 1K, 17% free 20117K/24076K, paused 13ms, total 13ms
D/dalvikvm( 1257): GC_CONCURRENT freed 18K, 17% free 20104K/24076K, paused 2ms+4ms, total 19ms
W/IdleConnectionHandler(28268): Removing a connection that never existed!
W/MovesProd.c(25181): buffer is empty, nothing to flush
D/dalvikvm( 3437): GC_CONCURRENT freed 403K, 3% free 16539K/16980K, paused 3ms+1ms, total 21ms

ここですよね、これ。

/ActivityThread(24582): Activity com.android.internal.app.ChooserActivity has leaked IntentReceiver com.android.internal.app.ResolverActivity$1@42df1160 that was originally registered here. Are you missing a call to unregisterReceiver()?
E/ActivityThread(24582): android.app.IntentReceiverLeaked: Activity com.android.internal.app.ChooserActivity has leaked IntentReceiver com.android.internal.app.ResolverActivity$1@42df1160 that was originally registered here. Are you missing a call to unregisterReceiver()?

漏れてる。

最近少しネットでこの話出てきています。

On Android API 19 (4.4) the intent.createChooser method causes IntentServiceLeak - Stack Overflow

FYI, this seems to be happening on Android 4.4 regardless of how many options there are. Change the intent type to "text/html" for example helps, but it also limits the number of apps that can actually be shared to. Any idea why Android 4.4 is causing this? – clu Nov 7 at 0:18

Seems like there's a serious issue with Android 4.4 as the issue occurs on Youtube, Tumblr and various other apps.

android - Why does Intent.createChooser() need a BroadcastReceiver and how to implement? - Stack Overflow

どうやら、KitKat(Android OS 4.4)のみの現象のようです。

開発者がアプリ側のコード内で回避する方法を記載されていますが。

Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
sendIntent.putExtra(Intent.EXTRA_TEXT, message);
sendIntent.setType("text/plain");

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
    // This will open the "Complete action with" dialog if the user doesn't have a default app set.
    context.startActivity(sendIntent);
} else {
    context.startActivity(Intent.createChooser(sendIntent, "Share Via"));
}

 

KitKatなAndroidユーザー側からするとどうやって回避すればいいのか。

通常、共有によるアプリ選択を(意図的な「常時」チェックで)固定した場合はその固定したアプリの「デフォルトでの設定」をキャンセル(設定を消去)すれば解除されるのですが、以下な操作で。

「設定」-「アプリ」から固定している連携先アプリを選択。

20131116-101207-2

けれど、ここを見ても、グレーアウトで設定されていなかった。

とりあえず、あたしは、

その固定した連携先アプリを一度「アンインストール」する

ということで正常に戻しましたが。

どうなのこれ。


関連ワード:  AndroidGoogle評判速報開発