我在Android中有一项服务,它使用UserStreamListener不断检查用户是否有新的推文。它在onStatus(Status status),
中完美运行,但是当我尝试使用onDirectMessage(DirectMessage dm),
进行测试时,没有显示任何内容。
我在Twitter控制台上启用了正确的权限(读取,写入和访问直接消息)。
StatusListener listener = new UserStreamListener()
{
@Override
public void onDeletionNotice(StatusDeletionNotice arg0)
{
}
@Override
public void onScrubGeo(long arg0, long arg1)
{
}
@Override
public void onStallWarning(StallWarning arg0)
{
}
@Override
public void onStatus(Status status)
{
User user = status.getUser();
String screenName = user.getScreenName();
String profileImage = user.getProfileImageURL();
String text = status.getText();
makeNotification(profileImage, screenName, text);
}
@Override
public void onTrackLimitationNotice(int arg0)
{
}
@Override
public void onException(Exception arg0)
{
}
@Override
public void onBlock(User arg0, User arg1)
{
}
@Override
public void onDeletionNotice(long arg0, long arg1)
{
}
@Override
public void onDirectMessage(DirectMessage dm)
{
Log.v("Info", "HELLO WORLD"); // nothing shows up here when I have a new DM
}
@Override
public void onFavorite(User arg0, User arg1, Status arg2)
{
}
@Override
public void onFollow(User arg0, User arg1)
{
}
@Override
public void onFriendList(long[] arg0)
{
}
@Override
public void onUnblock(User arg0, User arg1)
{
}
@Override
public void onUnfavorite(User arg0, User arg1, Status arg2)
{
}
@Override
public void onUserListCreation(User arg0, UserList arg1)
{
}
@Override
public void onUserListDeletion(User arg0, UserList arg1)
{
}
@Override
public void onUserListMemberAddition(User arg0, User arg1, UserList arg2)
{
}
@Override
public void onUserListMemberDeletion(User arg0, User arg1, UserList arg2)
{
}
@Override
public void onUserListSubscription(User arg0, User arg1, UserList arg2)
{
}
@Override
public void onUserListUnsubscription(User arg0, User arg1, UserList arg2)
{
}
@Override
public void onUserListUpdate(User arg0, UserList arg1)
{
}
@Override
public void onUserProfileUpdate(User arg0)
{
}
};
twitterStream.addListener(listener);
twitterStream.user();