I'm having an issue with an acitivity for an android app, to make it simple I let there be three activities : the main M, the one that answers A and the one I start C.
So M starts A using startActivityOnResult, then A sends result to M and from there M starts S.
But for some reason, the layout of S doesn't update until the main method I call from there is finished (and when that method is finished the activity goes back to M anyway, so basically I only see the layout if I make the activity S not give the result and stand there doing nothing).
Here is some of the code :
In M starting S :
Intent intent = new Intent(MainActivity.this, getCamFind.class);
intent.putExtra("path", mCurrentPhotoPath);
startActivityForResult(intent, CAMFIND_REQUEST_CODE);
In S :
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_getcamfind);
receivedIntent = getIntent();
Log.d(TAG, "Received string : " + receivedIntent.getStringExtra("path"));
}
public void onStart(){
super.onStart();
try {
postCamResult(receivedIntent.getStringExtra("path"));
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
So here the main method I was talking about is postCamResult, it basically connects to a server using retrofit. At the end of this method is where I would usually put the few lines to send back the result intent. The problem being the layout waits for this method to finish for some reason ? so if I don't send the result intent, it will, after doing all the server related stuff, finally print my layout, but you know, I'd like my layout to appear as soon as I open the activity!
Thank you in advance !