在我的服务主题中:
public class Main_Service extends Service implements Runnable {
... }
我想发送广播数据:
new Thread(new Runnable() {
public void run() {
while (true) {
try {
Thread.sleep(10);
if (Draw_picture != null)
{
Log.i(TAG, "Picture copy");
}
Intent intent = new Intent();
intent.putExtra("picture", Draw_picture);
sendBroadcast(intent);
在其他线程中,我执行以下操作:
public Intent mServiceIntent;
mServiceIntent = new Intent(context, Main_Service.class);
context.startService(mServiceIntent);
在runnable方法中,我输入以下代码:
mpubl_picture = (Bitmap) mServiceIntent.getExtras().get("picture");
if (mpubl_picture != null)
{
Log.i(TAG, "mpubl_picture is not null ");
}
但是当我调试时, mpubl_picture = null,Draw_picture!= null。怎么了?