Example #1
0
        public BtScanner(Context context)
        {
            this.context = context;

            if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop)
            {
                if (Permission.Granted == ContextCompat.CheckSelfPermission(context, Android.Manifest.Permission.AccessFineLocation))
                {
                    Log.D(this, "This user is using the 5.0 bluetooth api");
                    scanDelegate = new Api21Scanner(manager.Adapter);
                }
                else
                {
                    Log.D(this, "This user is using the 4.3 bluetooth api due to rejected permissions");
                    scanDelegate = new Api18Scanner(manager.Adapter);
                }
            }
            else if (Build.VERSION.SdkInt >= BuildVersionCodes.JellyBean)
            {
                Log.D(this, "This user is using the 4.3 bluetooth api due to versioning");
                scanDelegate = new Api18Scanner(manager.Adapter);
            }
            else
            {
                // TODO [email protected]: Catch and display user message
                // No good, the user's device cannot support le connections.
                throw new Exception("Cannot create AndroidLeConnectionHelper: device version too old");
            }
        }
Example #2
0
 public AndroidLeConnectionHelper(AndroidION ion, BluetoothAdapter adapter)
 {
     this.ion     = ion;
     this.adapter = adapter;
     if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop)
     {
         scanDelegate = new Api21ScanDelegate(adapter);
     }
     else if (Build.VERSION.SdkInt >= BuildVersionCodes.JellyBean)
     {
         scanDelegate = new Api18ScanDelegate(adapter);
     }
     else
     {
         // TODO [email protected]: Catch and display user message
         // No good, the user's device cannot support le connections.
         throw new Exception("Cannot create AndroidLeConnectionHelper: device version too old");
     }
 }