0

I am developing an app for sending files and my problem is that when I share some file from outside, it always starts a new instance of the app, even if an already instance is running. To put it another way: I have to log in every time when I share something, even if I am already running the app in the background.

Are there any workarounds for this?

Thanks a lot!

1 Answers1

0

set android:alwaysRetainTaskState="true" and android:launchMode="singleInstance" to your very first activity in AndroidManifest

waqaslam
  • 67,549
  • 16
  • 165
  • 178
  • it does not work. when I try to share a file it still launches a new instance. – Szilard Mandici Mar 13 '12 at 13:50
  • paste your AndroidManifest and the code where you do this sharing by launching (if any) activity – waqaslam Mar 13 '12 at 14:14
  • the problem is that the launcher activity, which has the action.SEND action is no longer available because it is already destroyed. (it is a login window, after login I destroy it). But if I add to any other activity, which does live, the program crashes. Can you help me with that? Thanks. – Szilard Mandici Mar 13 '12 at 16:49
  • if you dont destroy your login activity, will it affect the flow of your application? – waqaslam Mar 13 '12 at 20:08
  • yes. I don't want the user to be able to go back to the login window by hitting the back button. But I managed to solve this issue. I set the other activities android:launchMode="singleInstance" and I start the launcher activity, but in the oncreate, if it is already started (I set some boolean value) then I navigate to a specific window. This way it works. But thanks for the tip with these two attributes. – Szilard Mandici Mar 13 '12 at 21:54