以下の様に記述してみましたがうまくいきません。 どうすればいいでしょうか。 エラーは The Method createBond() in the type BluetoothDevice is not applicable for the arguments() The method convertPinToBytes(String) is undefined for the type BluetoothDevice とでています。以下、ソースです。
private final BroadcastReceiver mReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction();
Log.d(TAG, "Action:" + action);
if (BluetoothDevice.ACTION_BOND_STATE_CHANGED.equals(action)) { Log.d(TAG, "ACTION_BOND_STATE_CHANGED"); BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); Method createBond = device.getClass().getMethod("createBond", new Class[] {}); boolean a = device.createBond(wifiInfo.getMacAddress()); boolean b = device.setPin(device.getAddress(), BluetoothDevice.convertPinToBytes("0000")); Log.d(TAG, "createBond:" + a + ", setPin:" + b); if (a && b) { Log.d(TAG, "AutoPairing Success !"); } }
毎日朝5時にリブートされるサーバのメモリにSQLiteデータベースを作成しています。 Cronが使えない関係上、リブート後の最初のWebへのアクセスで作成することにしているのですが、 サーバのアクセスログを見るのは大げさなので、 リブート後最初のアクセスであるという判定をプログラムでは行わず、 create時にif not existsをつけるか、一度selectしてみて、テーブルが存在しなかったら例外で作成するかという手順にしようと思っています。 それでどちらが最適解なんでしょうか? if not existsのほうが簡単ではありますが、毎回アクセスのたびにDB作成を試みる感じがして違和感があります。