Java 将可绘制图像从第1个活动传递到第2个活动不起作用(仅从第2个活动传递到第1个活动)

Java 将可绘制图像从第1个活动传递到第2个活动不起作用(仅从第2个活动传递到第1个活动),java,android,android-intent,android-studio,Java,Android,Android Intent,Android Studio,在此处输入代码这是我的第一个活动::>我需要: 1) 选择一个选项 2) 单击发送图像(从drawable)应转到第二个活动,但它不仅从第二个到第一个工作正常所有xml和清单文件都正确(我已仔细检查) 这是我的第二项活动==> package com.example.damianlopez.myassignment; import android.app.Activity; import android.content.Intent; import android.os.Bundle; imp

在此处输入代码
这是我的第一个活动::>我需要: 1) 选择一个选项 2) 单击发送图像(从drawable)应转到第二个活动,但它不仅从第二个到第一个工作正常所有xml和清单文件都正确(我已仔细检查)

这是我的第二项活动==>

package com.example.damianlopez.myassignment;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Toast;

public class Main22Activity extends AppCompatActivity {
    private RadioGroup radioGroupChoice2;
    private RadioButton radBurger;
    private RadioButton radScare;
    private RadioButton radSick;
    private Button toAlice;
    private ImageView currentImage;
    private ImageView scareImage;
    private ImageView sickImage;
    private final int MY_SELECTION2 = 222;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main22);

        //display app icon
        ActionBar ab = getSupportActionBar();
        ab.setDisplayShowHomeEnabled(true);
        ab.setIcon(R.mipmap.ic_launcher);
        //Buttons
        radioGroupChoice2 = (RadioGroup)findViewById(R.id.radGroupChoice);
        //toAlice = (Button) findViewById(R.id.sndToAlice);

        //get the intent called
        Intent myLocalIntent = getIntent();

        Bundle myBundle = myLocalIntent.getExtras();
        myLocalIntent.putExtras(myBundle);
        setResult(Activity.RESULT_OK, myLocalIntent);


    }
    public void onClickButton2(View v){

        try {
            radioGroupChoice2 = (RadioGroup) findViewById(R.id.radGroupChoice);
            if (radioGroupChoice2.getCheckedRadioButtonId() == -1) {
                Toast.makeText(getApplicationContext(), "Please make a selection", Toast.LENGTH_LONG).show();
            } else {
                Intent myIntent2 = new Intent();
                Bundle myBundle2 = new Bundle();
                int myImage = radioGroupChoice2.getCheckedRadioButtonId();
                myBundle2.putInt("selectedImage", myImage);
                myIntent2.putExtras(myBundle2);
                setResult(Activity.RESULT_OK, myIntent2);

            }
        }catch(Exception e) {

        }
        finish();
   @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_main22, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }

}

你怎么知道它是从2到1活动工作的?我正在寻找的是,在ActivityResult中的第一个活动中没有使用myData的操作,因为在我的第二个活动UI上,我选择了一个图像单击发送消息,它会将该图像显示回我的第一个活动
package com.example.damianlopez.myassignment;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Toast;

public class Main22Activity extends AppCompatActivity {
    private RadioGroup radioGroupChoice2;
    private RadioButton radBurger;
    private RadioButton radScare;
    private RadioButton radSick;
    private Button toAlice;
    private ImageView currentImage;
    private ImageView scareImage;
    private ImageView sickImage;
    private final int MY_SELECTION2 = 222;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main22);

        //display app icon
        ActionBar ab = getSupportActionBar();
        ab.setDisplayShowHomeEnabled(true);
        ab.setIcon(R.mipmap.ic_launcher);
        //Buttons
        radioGroupChoice2 = (RadioGroup)findViewById(R.id.radGroupChoice);
        //toAlice = (Button) findViewById(R.id.sndToAlice);

        //get the intent called
        Intent myLocalIntent = getIntent();

        Bundle myBundle = myLocalIntent.getExtras();
        myLocalIntent.putExtras(myBundle);
        setResult(Activity.RESULT_OK, myLocalIntent);


    }
    public void onClickButton2(View v){

        try {
            radioGroupChoice2 = (RadioGroup) findViewById(R.id.radGroupChoice);
            if (radioGroupChoice2.getCheckedRadioButtonId() == -1) {
                Toast.makeText(getApplicationContext(), "Please make a selection", Toast.LENGTH_LONG).show();
            } else {
                Intent myIntent2 = new Intent();
                Bundle myBundle2 = new Bundle();
                int myImage = radioGroupChoice2.getCheckedRadioButtonId();
                myBundle2.putInt("selectedImage", myImage);
                myIntent2.putExtras(myBundle2);
                setResult(Activity.RESULT_OK, myIntent2);

            }
        }catch(Exception e) {

        }
        finish();
   @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_main22, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }

}