Android Code Snippet Calculator Intent

Discussion in 'Code Snippets' started by Jeremy Tipton, Jun 22, 2018.

Tags:
  1. Jeremy Tipton

    Jeremy Tipton Member Licensed User

    I am reposting this bit of code for those who want a simple way to call the calculator's intent on any phone. It took me a few hours to find this and thought others may find it helpful.

    Code:
    Dim Pm As PackageManager
       
    Dim Inte As Intent
       
    Dim Packages As List
       
    Dim st As String

       Packages = Pm.GetInstalledPackages
      
       
    For i = 0 To Packages.size - 1
          st=Packages.Get(i)
          
    If st.Contains("calc") =True Then
             Inte=Pm.GetApplicationIntent(st)
                    
    If Inte.IsInitialized Then   StartActivity(Inte)
                
    Exit
          
    End If
       
    Next
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Same implementation with For Each:
    Code:
    Dim Pm As PackageManager 'Phone library
    Dim Inte As Intent
    For Each st As String In Pm.GetInstalledPackages
       
    If st.Contains("calc") =True Then
           Inte=Pm.GetApplicationIntent(st)
           
    If Inte.IsInitialized Then StartActivity(Inte)
           
    Exit
       
    End If
    Next
     
    DonManfred likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice