0
B를 다시 시작한 후 활동 A-> B-> A에서 이동하는 데 문제가 있습니다. B가 끝난 후에 의도가 A로 반환되는 방법을 엉망으로 만들지 않고 활동 B를 다시 시작하려면 어떻게해야합니까?활동이 다시 시작될 때 데이터를 반환하지 않습니다.
B는이 코드 A로부터 호출됩니다
public void activityFunction(Context gameContext){
//This function was made to pass the player class back and forth between
setContentView(R.layout.loadingscreen);
Intent i = new Intent(gameContext, gamePanel.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivityForResult(i,1);
}
B 조 경기 활동이 코드로 다시 설정됩니다 :이 코드 A와
setContentView(R.layout.loadingscreen);
Intent i = getIntent();
finish();
startActivity(i);
B 완료 및 반환 :
public void levelOver(){
setContentView(R.layout.loadingscreen);
Intent resultIntent = new Intent();
resultHolder results = new resultHolder(playerStats);
resultIntent.putExtra(.......);
resultIntent.putExtra(.......);
resultIntent.putExtra(.......);
resultIntent.putExtra(.......);
setResult(Activity.RESULT_OK, resultIntent);
finish();
}
다음은 onActivity가 A
에서 호출되는 위치입니다. 10protected void onActivityResult(int requestCode, int resultCode, final Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch(requestCode) {
case (1) : {
if (resultCode == Activity.RESULT_OK) {
returnedWithResults = true;
new AsyncReturnGameData().execute(data);
}
break;
}
}
}
활동 B는 다시 시작되지 않는 한 100 % 시간을 반환합니다. 다시 시작되면 오류를 반환합니다. 올바른 방향으로 나를 가리키는 어떤 도움도 크게 감사 할 것입니다. 감사!
죄송합니다. 이것은 옳은 대답이다. – HarshMarshmallow