來自服務的Android更新活動UI我有一項一直在檢查新任務的服務。如果有新任務,我希望刷新ActivityUI以顯示該信息。我確實找到了https:/github.com/CommonsGuy/CW-andtutorials/tree/master/18-LocalService/這個例子。這是個好辦法嗎?還有其他的例子嗎?
3 回答

湖上湖
TA貢獻2003條經驗 獲得超2個贊
IntentFilter filter = new IntentFilter(); filter.addAction("com.hello.action"); updateUIReciver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { //UI update here } }; registerReceiver(updateUIReciver,filter);
Intent local = new Intent();local.setAction("com.hello.action");this.sendBroadcast(local);
unregisterReceiver(updateUIReciver);
- 3 回答
- 0 關注
- 491 瀏覽
添加回答
舉報
0/150
提交
取消