Show A License Agreement In Android Application
Solution 1:
onCreateDialog has been deprecated. Use dialog fragment instead. The advantage will be that the code for displaying dialog will be moved from activity and you can then display dialog from any activity. Also move
SharedPreferencessetting= getSharedPreferences(IConstant.Map_License, 0);
booleanmapLicenseAccept= setting.getBoolean(IConstant.Map_License, false);
to a utility method like isLicenceAccepted and similarly for storing the data
SharedPreferencessettings= getSharedPreferences(IConstant.Map_License, 0);
SharedPreferences.Editoreditor= settings.edit();
editor.putBoolean(IConstant.Map_License, true);
editor.commit();
to method like acceptLicence in utility.
You can find how to make communication between dialog Fragment and your activity here. In your interface instead of onArticleSelected
you will have to implement two methods onLicence accepted and onLicenceRejected. Implement the interface in you activity override these two methods and take appropriate action.
Solution 2:
Where to put this dialog?
Right at the beginning, when the user opens the app for the first time. Keep track of that by saving it in your shared preferences, if this dialog has been already shown or not. You don't have to create a separate activity for this. You could, but most apps I've seen out there don't.
How to close the app if user hit "Reject"
Just finish the Activity and also save that in your shared preferences as well. So every time the user opens your app you check weather the boolean value for "hasUserAcceptedOurAgreement" is true or not and proceed depending on that.
I'm only answering from a technical standpoint on how this could be done reliably. I'm not a lawyer, but as far as I know, it's perfectly valid to just submit your license agreement to the play store, so it's available from the applications application page (Why else would there be this option?).
Post a Comment for "Show A License Agreement In Android Application"