我正在将Google +1按钮集成到我的Android应用中。我在MainActivity中使用与PlusOne按钮相同的片段和子活动(SearchActivity)。在SearchActivity中,按钮工作正常。 Logcat显示:
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
在我的MainActivity中,AccountChooser永远不可见。按下+1按钮只会启动加载程序一段时间,然后返回默认的红色按钮。
Logcat显示:
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
所以它抱怨
registerConnectionCallbacks():listener bjh @ 42ae18e0已经注册
为什么会这样,以及如何预防呢?我该怎么调试/进一步调查呢?如上所述,+1按钮在同一片段中只是一个不同的活动。这些活动继承了相同的父类,所以不应该有太大的区别。
感谢您的任何提示!
答案 0 :(得分:0)
我明白了。它与android:launchMode
中配置的AndroidManifest.xml
有关。将launchMode设置为singleInstance
时,+1按钮不起作用。
我使用其他launchModes singleTop,singleTask和标准版成功测试了它。