Question

I am integrating a Google +1 button into my Android app. I am using the same fragment with a PlusOne button in my MainActivity and a child activity (SearchActivity). In the SearchActivity the button works fine. Logcat shows:

I/ActivityManager(13953): START u0 {act=com.google.android.gms.plus.action.PLUS_ONE cmp=com.google.android.gms/.plus.plusone.PlusOneActivity (has extras)} from pid 3897
I/ActivityManager(13953): Start proc com.google.android.gms.ui for activity com.google.android.gms/.plus.plusone.PlusOneActivity: pid=4061 uid=10010 gids={50010, 3003, 1007, 3002, 3001, 1028, 1015, 1006, 2001, 3006}
I/MultiDex( 4061): load(/data/app/com.google.android.gms-2.apk, forceReload=false)
I/MultiDex( 4061): Need extracted file /data/data/com.google.android.gms/files/secondary-dexes/com.google.android.gms-2.apk.classes2.zip
I/MultiDex( 4061): No extraction needed for /data/data/com.google.android.gms/files/secondary-dexes/com.google.android.gms-2.apk.classes2.zip of size 1547068
D/GCM     ( 2864): GcmService start Intent { act=com.google.android.gms.INITIALIZE flg=0x10 pkg=com.google.android.gms cmp=com.google.android.gms/.gcm.GcmService } com.google.android.gms.INITIALIZE
I/ActivityManager(13953): START u0 {cmp=com.google.android.gms/.plus.activity.AccountSignUpActivity (has extras)} from pid 4061
I/ActivityManager(13953): Displayed com.google.android.gms/.plus.plusone.PlusOneActivity: +2s158ms
I/ActivityManager(13953): Displayed com.google.android.gms/.plus.activity.AccountSignUpActivity: +1s908ms
I/ActivityManager(13953): START u0 {act=com.google.android.gms.common.account.CHOOSE_ACCOUNT cmp=com.google.android.gms/.common.account.AccountPickerActivity (has extras)} from pid 4061
I/ActivityManager(13953): Displayed com.google.android.gms/.common.account.AccountPickerActivity: +1s283ms

In my MainActivity the AccountChooser never gets visible. Pushing the +1 button just starts a loader for a little while before returning to the default red button.

Logcat shows:

I/ActivityManager(13953): START u0 {act=com.google.android.gms.plus.action.PLUS_ONE cmp=com.google.android.gms/.plus.plusone.PlusOneActivity (has extras)} from pid 4530
W/GmsClientEvents( 4530): registerConnectionCallbacks(): listener bjh@420c6a40 is already registered
I/ActivityManager(13953): Start proc com.google.android.gms.ui for activity com.google.android.gms/.plus.plusone.PlusOneActivity: pid=4727 uid=10010 gids={50010, 3003, 1007, 3002, 3001, 1028, 1015, 1006, 2001, 3006}
I/MultiDex( 4727): load(/data/app/com.google.android.gms-2.apk, forceReload=false)
I/MultiDex( 4727): Need extracted file /data/data/com.google.android.gms/files/secondary-dexes/com.google.android.gms-2.apk.classes2.zip
I/MultiDex( 4727): No extraction needed for /data/data/com.google.android.gms/files/secondary-dexes/com.google.android.gms-2.apk.classes2.zip of size 1547068
D/GCM     ( 2864): GcmService start Intent { act=com.google.android.gms.INITIALIZE flg=0x10 pkg=com.google.android.gms cmp=com.google.android.gms/.gcm.GcmService } com.google.android.gms.INITIALIZE
W/GmsClientEvents( 4530): registerConnectionCallbacks(): listener bjh@42ae18e0 is already registered

So it complains about

registerConnectionCallbacks(): listener bjh@42ae18e0 is already registered

Why could that be and how to prevent it? How could I debug/further investigate this? As written above the +1 button is in the same fragment just a different activity. The activities inherit the same parent classes so there should not be much of a difference.

Thank you for any hints!

Était-ce utile?

La solution

I figured it out. It has to do with the android:launchMode configured in the AndroidManifest.xml. With launchMode set to singleInstance the +1 button does not work.

I successfully tested it with the other launchModes singleTop, singleTask and standard.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top