Detect other packages(apks) installed on Android?

Hey all,

I am having some trouble implementing some code into a game. I have been trying to unlock features in my game based on whether or not the player has another app installed on their system.

This is the code I been told to use:

public static boolean isGameInstalled(Context context)
{
List<PackageInfo> packages = context.getPackageManager().getInstalledPackages(0);

for(PackageInfo pi : packages)
{
    if (pi.packageName.equalsIgnoreCase("com.company.app"))
        {
        return true;
        }
    }
    return false;
}

If I put this in a c# script and try to save it out like this:

using UnityEngine;
using System.Collections;

public class TestScript : MonoBehaviour {


    // Use this for initialization
    void Start () {

   
    }
   
    // Update is called once per frame
    void Update () {
   
    }


    public static boolean isGameInstalled(Context context)
    {
        List<PackageInfo> packages = context.getPackageManager().getInstalledPackages(0);
           
            for(PackageInfo pi : packages)
        {
            if (pi.packageName.equalsIgnoreCase("com.company.app"))
            {
                return true;
            }
        }
        return false;
    }




}

I get the following errors in Unity:

TestScript.cs(21,97): error CS1525: Unexpected symbol `’
TestScript.cs(37,1): error CS8025: Parsing error

I know this is probably a logic/context problem that I don’t understand, as I have basically learned how to write code by reading online forums and what not. I am not a complete moron and hope this just doesn’t seem stupid, but I would really like some help to figure out why this code is not working for me.

Thanks for any advice you can offer.

I am a total dummy, the more I look into it, the more I am certain that the code snippet I was given is Java. Sorry for wasting anyones time.