1

In my service-thread:

public class Main_Service extends Service implements Runnable {
... }

I want to send broadcast data:

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);

In other a Thread I do the following:

public Intent mServiceIntent;
mServiceIntent = new Intent(context, Main_Service.class);
context.startService(mServiceIntent);

In the runnable method I put the following code:

mpubl_picture = (Bitmap) mServiceIntent.getExtras().get("picture");
 if (mpubl_picture != null)
    {
    Log.i(TAG, "mpubl_picture is not null ");
    }

But when I debug, mpubl_picture = null, Draw_picture!=null. Whats wrong?

4

0 回答 0