0

I'm calling a new intent for sharing from my Main Activity. It is needed to load or come back to Main Activity after user finish sharing or cancel sharing.

I use following code to call the new intent. I can't figure out how to come back to main activity again.

                Intent shareImage = new Intent();
                shareImage.setAction(Intent.ACTION_SEND);
                String mimeTyp = "*/*";
                shareImage.setType(mimeTyp);
                shareImage.putExtra(Intent.EXTRA_TEXT, "This is the text that will be shared.");
                shareImage.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://"+finalimagepath));

                startActivity(Intent.createChooser(shareImage, "Share Click")); 

with this code it doesn't come to the main activity after finishing the sharing intent.

Ruwan Dissanayaka
  • 305
  • 1
  • 8
  • 19
  • So you are basically saying send this data to be handled by another activity from wherever. That other place does not have to return :-/ They could simply move on, but usually that is not the case. They should end their flow immediately after. However if they do, you can't do much about it. You could place a flag on the intent to remove them from history and reset the task in the case the user powers off and on their phone, it will reset to the place that started the intent. How does that sound? – Greg Giacovelli Oct 13 '12 at 06:51
  • return to a black screen when i debug it. it seems it cant come back to main activity. if I put finish() after above code it exits the application. – Ruwan Dissanayaka Oct 13 '12 at 06:51
  • @GregGiacovelli I tried to use flags. But not clear where should I put the flag and which flag i should use. Above code is in the main activity. and should i use the flag with this code like 'code' shareImage.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP); – Ruwan Dissanayaka Oct 13 '12 at 06:54
  • probably something like, `shareImage.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);` `shareImage.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);` But after what you just replied, I don't think this will fix a blank screen issue. That sounds more like your onResume() and onPause() and possibly onCreate() and onSaveInstanceState are a little messed up. – Greg Giacovelli Oct 13 '12 at 07:01
  • See this: http://stackoverflow.com/questions/4038479/android-go-back-to-previous-activity – lukewm Sep 11 '15 at 14:13

0 Answers0