大佬教程收集整理的这篇文章主要介绍了android – 在新线程中注册来自服务的广播接收器,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我已经检查了这篇文章Are Android’s BroadcastReceivers started in a new thread?,但我需要一个更具体的例子来说明使用COntext.registerReceiver(BroadcastReceiver接收器,IntentFilter过滤器,String broadcastPermission,Handler调度程序)
实际上我需要知道如何从服务创建一个新线程并注册接收器并附加到该线程.
非常感谢你.
RA
private Handler handler; // Handler for the separate Thread HandlerThread handlerThread = new HandlerThread("MyNewThread"); handlerThread.start(); // Now get the Looper from the HandlerThread so that we can create a Handler that is attached to // the HandlerThread // NOTE: This call will block until the HandlerThread gets control and initializes its Looper Looper looper = handlerThread.getLooper(); // Create a handler for the service handler = new Handler(looper); // Register the broadcast receiver to run on the separate Thread registerReceiver (myReceiver,intentFilter,broadcastPermission,handler);
以上是大佬教程为你收集整理的android – 在新线程中注册来自服务的广播接收器全部内容,希望文章能够帮你解决android – 在新线程中注册来自服务的广播接收器所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。