1

私のサービススレッドで:

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

実行可能なメソッドに、次のコードを入れます。

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 になります。どうしたの?

4

0 に答える 0