Android Question Check if app exists on device

Colin Evans

Active Member
Licensed User
Longtime User
Hi,
is it possible to check if a specific app is installed on an android device and then if it is run the app and if not install from a network address.

I want to kick of the application from a QR Barcode so I assume I'd have to have an url that runs a specific small app or form that checks if the application exists on the device and then does the if then options.

I may be way off in what I want to achieve but hopefully someone could point me in the right direction

Thanks
 

JohnC

Expert
Licensed User
Longtime User
If I understand you correctly, you would like user to be able to scan a QR Code, and if they have your app already installed on their phone, and if so, run it.

But if your app is not already installed on their device, you would like their device to navigate to your app's page in the play store?

If so, (and I have not done this myself) but I think that can be accomplished with "deep linking":


 
Upvote 0

Colin Evans

Active Member
Licensed User
Longtime User
Hi JohnC, thanks for the reply, yes basically I want the user to scan a QR Code and check if the app is installed if so run it, this is step one but unfortunately I'm not sure how to implement it and the second issue would be, if it isn't installed, install it from a url (not google play store) which I think I may understand how to do.

It's the first step I'm totally at a loss with
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
I have not done any work with deep linking, so I unfortunately can't offer any more help.

But I do think you might be able to redirect to another URL so the user can sideload your app.
 
Upvote 0

Colin Evans

Active Member
Licensed User
Longtime User
I'm not sure if it is possible to do what I want, basically from the scanning of the QR Code run a program held on a server to check if the app is installed on the phone, or just check if it is via some other means, I think that's my stumbling block... but thanks for replying anyway
 
Upvote 0

Douglas Farias

Expert
Licensed User
Longtime User
I have not tested...
but try
B4X:
Sub App_Exist(package As String) As Boolean
    Private appExist As Boolean = False
    Dim pm As PackageManager
    Dim packages As List
    packages = pm.GetInstalledPackages
    For i = 0 To packages.Size - 1
        If package = packages.Get(i) Then appExist = True
    Next
    Return appExist
End Sub


Sub Download_App(package As String)
    Try
        Private withGooglePlay As Intent
        withGooglePlay.Initialize (withGooglePlay.ACTION_VIEW, "market://details?id=" & package)
        StartActivity (withGooglePlay)
   
    Catch
        Private withoutGooglePlay As Intent
        withoutGooglePlay.Initialize (withoutGooglePlay.ACTION_VIEW, "https://play.google.com/store/apps/details?id=" & package)
        StartActivity (withoutGooglePlay)
    End Try
End Sub

to use...
B4X:
Log(App_Exist("com.facebook.katana"))
'Download_App("com.facebook.katana")

Requires Phone lib!
 
Last edited:
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
You are not expected to download a App from any url.
Google expect you using GooglePlayStore.

Deeplinking is the correct solution as already pointed out by @JohnC

But even here, the App MUST be installed by GooglePlayStore.
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
But even here, the App MUST be installed by GooglePlayStore.

Hey Don,

Not trying to contradict in any way....but I thought maybe deep linking can work with links other then with the play store.

I'm thinking this because often if I click on a youtube video link, it will prompt me to view the video in the browser or using the youtube app.

So, I was thinking that this guy could designate his URL to be the location of an APK on his website (that the user would side-load), but in the manifest he would "register" that particular URL as a deep link so that if the app is already installed on the users device, it will launch the app instead of navigating to that url (his website).

But again, I never did deep linking before, so my quick impression of how it works could be totally off-base.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Deeplinking does use GooglePlay as per Documentation.


You invite a User using Deeplinking:
- The user gets an email from google with a invitationLink.
- The User clicks on this link and is pointed to GooglePlay.
- If the app is not installed on the Device he get the chance to install it.
- He install the app and then open it. Google give your app the deeplink you defined on the first run. Do whatever you want to do with the Data (link, values) in the deeplink.

If the app already is installed on his device the app gets started when clicking the invitelink.
Google give your app the deeplink you defined when starting your app. Do whatever you want to do with the Data (link, values) in the deeplink.
 
Last edited:
Upvote 0

JohnC

Expert
Licensed User
Longtime User
OK - understood.
 
Upvote 0

Colin Evans

Active Member
Licensed User
Longtime User
Hi, thanks for all the input greatly appreciated,
I don't want to use Google play store, the app would reside on my network and when a visitor activates the QR Code and the checks show the app doesn't exist on their phone or device it would load the apk via an http address. So I'm still not sure whether doing it through a QR Code would be feasible as they wouldn't have the code to check if it was installed or not on their device.

Hope I'm making sense
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Hope I'm making sense
Not really. The User needs an App which reads the QRCode, analize the content and then uses Code to check if the app exists or not, download it and then install it.
No one QRCode Reader app is able to do that.

You need to write your own Reader with this functionality.
 
Upvote 0

Colin Evans

Active Member
Licensed User
Longtime User
Okay, many thanks to everyone who responded, I may have a look at Deeplinking and see if it offers a solution
 
Upvote 0

Colin Evans

Active Member
Licensed User
Longtime User
Thanks again to all who contributed, I figured it out in the end using a QR Code which invoked a web form which did what i needed, thanks again
 
Upvote 0
Top