0

im trying to create a BookReader, and the user can Open multiple Books to compare text btw then

so i have MainActivity(Book List) and

ReaderActivity(Activity that open the book)

i need the ReaderActivity to open multiple times example:

what i want:

User Open MainActivity, click in one Book and than Open the ReaderActivity at the selected book

press Android Process List (select the MainActivity) and than click in another book, so i will end with the MainActivity(only one) and two or more ReaderActivity, so he can easily change btw book using the Process List

but what is happening

User Open MainActivity, click in one Book and than Open the ReaderActivity at the selected book

press Android Process List (select the MainActivity) and than click in another book, BUT now it open the second book in the previosly

code that im using to open the second activity(that can open multiple instances and multiple books)

Intent i = new Intent(this, ReaderActivity.class);
      i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
            i.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
this.startActivity(i);

PS: without the NEW_DOCUMENT, it open the ReaderBook on top of MainActivity =/

user2582318
  • 1,607
  • 5
  • 29
  • 47
  • 1
    I am confused. Do you want to open a new book each time you click a book and keep the data how many books you have selected and finally compare them in ReaderActivity class? By default, ReaderActivity will open on top of MainActivity. You have to manually edit the back button code to indicate where you want to send the command or disable the button. –  Dec 19 '15 at 18:30
  • I'm also confused, show us your real code for doing this - the above is either pseudo code that doesn't make sense - or real code that is real bad! – Blundell Dec 19 '15 at 18:50
  • @IbtehazShawon sorry, the compare that i mean is just visual, imagine how Chrome Browser works in Android, you open a new tab and it show like a new activity in Android Task Manager, so you can easily enter in any tab you want and do this many times and for many tabs you have, i want this behaviour – user2582318 Dec 19 '15 at 18:52
  • @Blundell i edited the code so you can understand the code i = intent, and read my answer to Ibtehaz – user2582318 Dec 19 '15 at 18:55
  • I would simplify your flags to only use `Intent.FLAG_ACTIVITY_NEW_TASK` or `Intent.FLAG_ACTIVITY_NEW_DOCUMENT` then how does it behave? – Blundell Dec 19 '15 at 19:01
  • @Blundell it create the second activity but when i return(press process list and choose) to the MainActivity and click in another book, it reopen the first one created (doesnt create the second instance of ReaderActivity – user2582318 Dec 19 '15 at 19:10
  • With new_task it should create a new one. I think you're either doing something else wrong or looking at the problem wrong – Blundell Dec 19 '15 at 19:20
  • @Blundell NEW TASK just override the MainActivity =/ – user2582318 Dec 19 '15 at 19:21
  • You're right, try multiple task! http://developer.android.com/reference/android/content/Intent.html#FLAG_ACTIVITY_MULTIPLE_TASK `i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent. FLAG_ACTIVITY_MULTIPLE_TASK);` (fyi the docs say don't do this :-) ) and I was reading: http://stackoverflow.com/questions/9772927/flag-activity-new-task-clarification-needed – Blundell Dec 19 '15 at 19:25
  • @Blundell newTASK and Multiple Task has no effect, still the second task override the mainActivity, but using the New_DOCUMENT it has the expected behaviour, the worst thing is that new_document is > api21 – user2582318 Dec 19 '15 at 19:34
  • Yeah read the linked question I commented, there are many options including adding `taskAffinity` and other attributes in your `AndroidManifest` good luck! – Blundell Dec 19 '15 at 19:37
  • @Blundell i will take a look about this taskAffinity, if i found something usefull i post here to notify you, thank youuu – user2582318 Dec 19 '15 at 19:38

0 Answers0