Android Question Printing and PDF printer installation intent

Rusty

Well-Known Member
Licensed User
Longtime User
I would like to offer my clients a list of detected printers on their LAN on which they can print from the app.
In development, I installed it manually from your hyperlink in the Printing and PDF page on this blog.
However, when my users download my app from the PlayStore, I want to install it for them, with their permission and acceptance.
I've created code to programmatically install Uber on the user's machine but I'm lost to find out how to create the proper code to install for example the HP or Canon printer like:
HP printer: https://play.google.com/store/apps/details?id=com.hp.android.printservice
Cannon: https://play.google.com/store/apps/details?id=jp.co.canon.android.printservice.plugin
Any advice would be appreciated ...
Rusty
 

Rusty

Well-Known Member
Licensed User
Longtime User
Thanks Erel.
Any code snippets to
send an intent and open those links with Google Play
?

Also, how do I find the intent for the printer service? Like the Samsung Printer:
https://play.google.com/store/apps/...tservice&rdid=com.sec.app.samsungprintservice
or HP, Canon etc.

I need to check if it is installed before I try to install it.
B4X:
Dim UberInstalled As Int = pm.GetVersionCode("com.ubercab")
the above code I used to see if Uber was installed.

Also, I parsed all installed apps and logged their intents with this:
B4X:
'Finds if an app is installed and returns the starting intent
Private Sub ShowInstalledApps(FindApp As String) As Intent
    Dim RetCd As Intent
    Dim pm As PackageManager  'phone library
    
'    Try
'        RetCd = pm.GetApplicationIntent(FindApp)    'look immediately and return if exists
'        Return RetCd
'    Catch
'        Log("ShowInstalled error: "& FindApp & " - " & LastException)
'    End Try
    
    For Each pck As String In pm.GetInstalledPackages    'search through the installed apps, fallback
        Dim Name As String = pm.GetApplicationLabel(pck)
'       Dim imgv As ImageView
'        imgv.Initialize("imgv")
'        imgv.Background = pm.GetApplicationIcon(pck)
        If Name.ToLowerCase.Contains("print") Then
            RetCd = pm.GetApplicationIntent(pck)
            Log(Name & "  Intent: " & RetCd)
        End If
    Next
    Return RetCd
End Sub

AND received "Not initialized" for all of the printer services...

Print Spooler Intent: (Intent) Not initialized
Samsung Print Service Plugin Intent: (Intent) Not initialized
Print Service Recommendation Service Intent: (Intent) Not initialized
Canon Print Service Intent: (Intent) Not initialized
Bluetooth SPP Printing Intent: (Intent) Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 pkg=bt.spp.printing cmp=bt.spp.printing/.main }
HP Print Service Plugin Intent: (Intent) Not initialized
Thanks
 
Last edited:
Upvote 0

Rusty

Well-Known Member
Licensed User
Longtime User
This works beautifully, Thanks Erel.
Is there a way to get the uninstall the print app? I can't seem to find the intent of (for example) the one depicted in your last post #4.
Thanks
Rusty
 
Upvote 0
Top