我正在尝试在Android上实施Scringo登录状态更改。但我的广播接收器从未被调用过。 我已按照http://www.scringo.com/docs/android-guides/popular/handling-login-status-changes/
中所述的说明操作所以我注册了我的广播接收器:
<receiver android:name="com.jino.footster.MyReceiver">
<intent-filter>
<action android:name="com.scringo.LoginBroadcast" />
</intent-filter>
</receiver>
然后我定义了我的Broacast接收器:
package com.jino.footster;
import com.scringo.utils.ScringoLogger;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
public class MyReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals("com.scringo.LoginBroadcast")) {
boolean isLogin = intent.getExtras().getBoolean("isLogin");
String accountId = intent.getExtras().getString("accountId");
ScringoLogger.e("Got Login receiver: " + isLogin + ", " + accountId);
}
}
}
当我启动应用程序时,登录似乎成功:我在logcat中看到以下消息:
04-24 01:12:35.000:I / Scringo(4717):您的Scringo用户令牌是:a03fgalc5E
然而,我的广播接收器的onReceive方法永远不会被调用。
有人能帮忙吗?
谢谢
答案 0 :(得分:0)
您忘记了类别:
<receiver android:name="com.jino.footster.MyReceiver">
<intent-filter>
<action android:name="com.scringo.LoginBroadcast" />
<category android:name="com.jino.footster"/>
</intent-filter>
</receiver>