Stop All Trial versions of an App

timo

Active Member
Licensed User
Longtime User
If you want to distribute (out of the Market) a Trial version of yor App to a circle of persons and you don't know how many installations and who is really testing it, how can you stop all those installations at the same time?

I've tried to solve using HttUtils (not sure if I used it the right way). I've loaded to a webserver a single text file (here named 'yourFile.txt') that contains the text 'OK'. As long as 'yourFile.txt' contains 'OK' trial Apps work. If you change 'OK' to something else, Trial Apps stop working.

But I've noticed one thing (still due to my not understanding 100% httpUtils): If you change the content of 'yourFile.txt', trial versions continues working for a while because, I suppose, it reads 'OK' from the cache (I think it acts like the licensing protection of the Market). They work till the cache is not empty or you turn the phone Off. It's not a big problem, but if I could manage it better I would prefer.

I know, it is not a 100% secure method, but enough for my needs.

I just want to know if my code (from Erel's example) is correct or if somethings is wrong/missing. Thank you.
B4X:
 'Activity module
Sub Process_Globals
   Dim b4a As String
   b4a = "http://yourWebServerName/yourDir/yourFile.txt"
End Sub

Sub Globals

End Sub

Sub Activity_Create(FirstTime As Boolean)
'Activity.LoadLayout("yourLayout")
ProgressDialogShow("connecting...")

   HttpUtils.CallbackActivity = "Main" 'Current activity name.
   HttpUtils.CallbackJobDoneSub = "JobDone"
   HttpUtils.Download("Job1", b4a)
   
End Sub

Sub Activity_Resume
   'Check whether a job has finished while the activity was paused.
   If HttpUtils.Complete = True Then JobDone(HttpUtils.Job)
End Sub

Sub UrlDone(Url As String)
   Log("URLDONE " &Url & " done")
End Sub

Sub JobDone (Job As String)
Dim s As String
   
If HttpUtils.IsSuccess(b4a) Then

   s = HttpUtils.GetString(b4a)
         
      If s="OK"    Then 
         ProgressDialogHide
         Msgbox("Trial is "&s,"AppTitle")
      Else
         ProgressDialogHide
         Msgbox("Trial out of date.","AppTitle")
         Activity.Finish
      End If
   
Else
   
   ProgressDialogHide
   Msgbox("Connection error,"&CRLF&"try again later.","AppTitle")
   Activity.Finish
   
End If

HttpUtils.Complete = False

End Sub
 
Last edited:

Kevin

Well-Known Member
Licensed User
Longtime User
As best I can tell the code looks okay.

I don't know if the cache would still have an effect on the reliability of your code, but perhaps you could do one of the following:

1) Check for the existence of the text file. If it comes back as error / not found, this could mean that the trial is valid. When you want the trial to be over, put the file on your server. The presence of the file would indicate that the trial is over. The problem with this approach is if for some reason your server is down or the user's internet connection is down then it will assume the trial is valid unless you can determine the reason it failed (perhaps by examining the contents of the response).

2) Use two files. Check for one file as a test to see if there is communication. This file should always be there. If it can't download it then there is something wrong with your server or the user's internet connection and you can handle this how you like. If the file is there, then start another download of the second file. If it is not there, the trial is valid. If it is there, the trial is over.

I don't know if caching will cause this not to work. I suppose it could cache the response saying the file was not there and even if you add the file it may still use the cache saying it is not there. Or perhaps it will now see the file and override the cache with the file's content. Shouldn't take too long to test it to see if that approach would work or not.

Or perhaps someone else knows how to clear the cache or make it always fully re-download a file?
 
Upvote 0

timo

Active Member
Licensed User
Longtime User
There is no cache.

What might happen is that the user presses on the home screen and then returns to your application. In this case the activity may not be destroyed and therefore do not need to be recreated.

I've tried changing the file to 'stop' and reopen the App. It still give me the 'OK', even after a clear cache, delete data or even a force close (from settings). It runs till i make the phone OFF, restart it and reopen the App. Only at this point it says 'Trial out of date'.
I really can't understand what happens:BangHead:

x Kelvin: All works fine, in any situations. Only what I described is a bit strange. For some unknown reason ( to me) the 's' variable is still kept in memory for a certain time, even after a force close. Thanks.
 
Last edited:
Upvote 0

timo

Active Member
Licensed User
Longtime User
Sorry if I come back on this thread, but on my Galaxy S Plus if I put on the web server a YourFile.txt containing "STOP" it continues reading "OK" of the old one, till I make the phone OFF. After restarting it reads "STOP".
Can someone explain me why?
 
Upvote 0

timo

Active Member
Licensed User
Longtime User
Sorry, the project I can't. Anyway to test the code you have to access a web hosting in order to change the content of YouFile.txt from 'OK' to some else content. You think that the rest of the App can play a rule in this behaviour?
 
Last edited:
Upvote 0

timo

Active Member
Licensed User
Longtime User
If I add this line it works on phone too. This means that 's' goes strangely walking somewhere.

At the end, I think I have to change the way doing it.

Thank you anyway.

B4X:
...
If s="OK"     Then  
    ProgressDialogHide            
    Msgbox("Trial is "&s,"AppTitle")   

 'added: 
    s="other"
 'end added 

Else
...
 
Upvote 0

Penko

Active Member
Licensed User
Longtime User
Unfortunately, we can't do much without the other code(I don't accuse you of not posting it). I'd say the following: check once again all references to s and see if its value is somehow changed.

You know that it could work just due to a bug in the Emulator. Put breakpoints at all references to "s" and monitor its value.

Report back.
 
Upvote 0
Top