0

I have a simple single-activity app. I now want to add another page for the EULA, displayed when the user presses a button.

Do I need to define another activity for that?

Would defining another <intent-filter> within the existing <activity> suffice?

ef2011
  • 10,431
  • 12
  • 49
  • 67
  • 1
    I guess it really depends on what you mean by "display the EULA". Do you need a full activity? Can you display it inside a dialog using a WebView? What format does it have? – dmon May 13 '11 at 20:32
  • @dmon Excellent questions. The idea is this: I want my single-screen (currently) app to have a button that takes you (the end-user) a page that covers the entire screen (for easy reading) which has a PayPal button "Pay with PayPal". I could theoretically replace the entire content of the current screen (RelativeLayout) with the EULA's TextView, but I am afraid this is an ugly solution which requires tracking the state of the program, when Android already has all these mechanisms built-in. Please let me if I am still not clear. – ef2011 May 13 '11 at 20:46

2 Answers2

2

No you do not need a new activity in the manifest. I suggest the following: Download and add this class to your project: http://code.google.com/p/apps-for-android/source/browse/trunk/DivideAndConquer/src/com/google/android/divideandconquer/Eula.java?r=93

After that put a text file, containing the EULA text into the "asset" application folder. A sample Eula you can find here: http://www.developer-resource.com/sample-eula.htm

Finally call Eula.show(this) in the Create event handler of your main Activity or in your example in the listener of the button.

Keep in mind, that this class tracks what the user has chosen (accept/decline). But you can overwrite this: The following code should be inserted at the begining of show() method in the provided Eula class: preferences.edit().putBoolean(PREFERENCE_EULA_ACCEPTED, false).commit(); Now the Eula will show up with every button click...

tobias
  • 2,322
  • 3
  • 33
  • 53
  • Wow! This looks even better than the dialog idea. Let me check this out. In the meanwhile, +1. – ef2011 May 13 '11 at 23:50
1

You can post a Dialog if that is what you want without creating another activity. So create a dialog using a builder and return it in getInstanceEula, setCancelable(false) if you want it to be blocking, call showDialog(DIALOG_EULA), and call getInstanceEula in onCreateDialog. It would not cover the entire screen, but you can make it scrollable.

JAL
  • 3,319
  • 2
  • 20
  • 17
  • Thank you! Already +1 for the suggestion. I'll try it and accept if it works for me. :) – ef2011 May 13 '11 at 22:19
  • Initial version works, but it's not scrollable. How do I make the dialog content scrollable? Thanks! – ef2011 May 13 '11 at 23:49
  • @ef2011 if you want the entire contents to be scrollable, just wrap the entire xml file except line 1 in a scrollview. You can do really cool stuff like scrolling only the body not the header and footer by embedding a scrollview in a relativelayout, OR even scroll with fixed floating buttons on the lower right hand corner etc! I tried the excellent open source EULA code, but IMHO it has a bug, it goes away on orientation change:) – JAL May 14 '11 at 00:10
  • The open source EULA code works for me even on orientation change. – ef2011 May 17 '11 at 13:58