How to manage/securize application

priusfan

Member
Licensed User
Longtime User
Bonjour,
I have 3 different applications running on tablets (ASUS TF101):
a phonebook with generic search on company name or contact name (39 000 phone nbrs), this one works perfectly on phones.
a kind of CRM (8000 customers with their key figures),
and something to compare products and access to technical docs on pdf.
they are using the same DB (18MB today).

I would like to show the user only one application showing the 3 options,
this app would start by asking a code and after 3 errors would delete the DB and the folder containing the technical docs (this is to protect the content in case of tablet lost or stolen). From this app, I would store somewhere in a file a kind of key which would be checked by the called apps.

So my question is just: how to launch another independent apk? (detailed exemple).

Sorry, I did'nt find the way to do it in the doc neither in this forum...

PS: sqlite on tablets provides excellent response time on tablets and the salesmen where I work are full of respect to me because of B4A...
 

thedesolatesoul

Expert
Licensed User
Longtime User
You can launch another application:

B4X:
Dim in As Intent
Dim pm As PackageManager
in = pm.GetApplicationIntent("com.google.android.youtube")
If in.IsInitialized Then StartActivity(in)
StartActivity(in)

This is described here:Basic4android - Phone

However, there is already a security flaw in your approach. If anyone opens one of the 3 apks directly then they would be able to by-pass security codes.
 
Upvote 0

priusfan

Member
Licensed User
Longtime User
icon_jap.gif
thank you, this is exactly what I was looking for.
icon_jap.gif

regarding security flaw, do not worry:
each called apk will check the key stored somewhere, containing a mix from the actual date, prepared by the main application.
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
If in.IsInitialized Then StartActivity(in)
StartActivity(in)

Please, help to understand what it means.
Intent "in" object must be initialized for start, but how to initialize it.
Who\where should initialize it, if we only check IsInitialized ?
Latest line gives error about first init is needed.
 
Upvote 0

thedesolatesoul

Expert
Licensed User
Longtime User
B4X:
in = pm.GetApplicationIntent("com.google.android.youtube")
The method GetApplicationIntent returns an intent that is then stored in 'in'.
If the application 'youtube' does not exist then nothing will be returned and 'in' will remain uninitialised.
You probably do not have this application on your device.
And yes, the last line is probably not needed.
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
thedesolatesoul, thanks.

I did this:

B4X:
Dim a As PackageManager, b As List, b2 As List
   b = a.GetInstalledPackages
   b2.Initialize
   For i=0 To b.Size-1
      b2.Add(a.GetApplicationLabel(b.Get(i)))
   Next

   c = InputList(b2, "Select application:",-1)
   If c <> DialogResponse.CANCEL Then
      Dim d As Intent
      d.Initialize(d.ACTION_VIEW,0)                   ' without this init i always get error :-(
      d = a.GetApplicationIntent(b.Get(c))
      If d.IsInitialized Then
         Try
            StartActivity(d)
         Catch
            ToastMessageShow("Wrong application, error during starting", False)
         End Try
      Else
         ToastMessageShow("Wrong application, cannot start", False)
      End If
         End If
 
Upvote 0
Top