如何在PubSub中获取离线消息?使用Smack库.搜索后我找到了一个如下所示的答案:
// Create a pubsub manager using an existing XMPPConnection
PubSubManager mgr = PubSubManager.getInstanceFor(con);
// Get the node
LeafNode node = mgr.getNode("testNode");
List<? extends Item> items = node.getItems(100);
Run Code Online (Sandbox Code Playgroud)
但node.getItems(100)返回最后100条消息,也可以在线和离线.
1)如何使用smack跟踪pubsub中的在线和离线消息?
2)是否可以使用smack在pubsub中获取未读消息计数?如果是,那么如何实现呢?
3)如何知道谁(发布者)在节点中发送此消息?
我刚从这里 和这里浏览了Smack和PubSub的文档,但没有找到与我的查询相关的解决方案.那么有人可以帮我解决这个问题吗?
我想定期向服务器发送数据,我正在使用后台Service,但我希望在数据更新时发送,并且我正在进入的更新数据Activity和Service后台运行..所以我怎么能通过数据运行Service的Activity.使用Intent我只能在启动时发送一次数据Service.
Intent serviceIntent= new Intent(DriverActivity.this,demoService.class);
serviceIntent.putExtra("token", token);
startService(serviceIntent);
Run Code Online (Sandbox Code Playgroud) 我在 RadioGroup 中有两个 RadioButton,最初都未选中。如果 RadioButton 已经被选中,我想取消选中它。我试过了,但我做不到。当我选择任何单选按钮时,第一次不会将状态更改为选中状态,如果我第二次选择相同的单选按钮,则它会更改其状态,如果我选择其他单选按钮,如果一个按钮被选中,则它也不会更改状态第一次和所有按钮都取消选中任何人都可以帮助我吗?我的代码如下...
radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) {
RadioButton checkedRadioButton = (RadioButton)group.findViewById(checkedId);
pus="";
boolean isChecked = checkedRadioButton.isChecked();
if(isChecked){
checkedRadioButton.setChecked(false);
}else{
checkedRadioButton.setChecked(true);
}
}
Toast.makeText(context, pus, Toast.LENGTH_SHORT).show();
}
});
Run Code Online (Sandbox Code Playgroud)
<RadioGroup
android:id="@+id/rdbt_group"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:gravity="center"
android:orientation="horizontal" >
<RadioButton
android:id="@+id/radio_no"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/rbtn_selector"
android:button="@null"
android:gravity="center"
android:paddingBottom="5dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="5dp"
android:clickable="true"
android:textColor="@drawable/rbtn_textcolor_selector"
android:textSize="15sp" />
<RadioButton
android:id="@+id/radio_yes"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:button="@null"
android:clickable="true"
android:textSize="15sp"
android:background="@drawable/rbtn_selector"
android:textColor="@drawable/rbtn_textcolor_selector"
android:padding="5dp"
android:gravity="center"
/>
</RadioGroup>
Run Code Online (Sandbox Code Playgroud)