私は正直なところ、sdkを変更せずにこれを行う方法を考え出すことができませんでした。あなたがOEMであれば、それは(私は4.3によ)簡単です:
パッケージ/アプリケーション/設定/のAndroidManifest.xmlで、ペアリングダイアログのインテントフィルタをコメント枠組みで
<activity android:name=".bluetooth.BluetoothPairingDialog"
android:label="@string/bluetooth_pairing_request"
android:excludeFromRecents="true"
android:theme="@*android:style/Theme.Holo.Dialog.Alert">
<!-- <intent-filter>
<action android:name="android.bluetooth.device.action.PAIRING_REQUEST" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter> -->
</activity>
をこの定数
@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
public static final String ACTION_PAIRING_REQUEST =
"android.bluetooth.device.action.PAIRING_REQUEST";
及びこの方法から@hide Javadocの注釈を削除/base/core/java/android/bluetooth/BluetoothDevice.java
public boolean setPairingConfirmation(boolean confirm)
次に、BluetoothDevice.PAIRING_REQUESTアクションのために、自分のアクティビティまたはブロードキャストレシーバを登録します。この放送受信機は、(何のピンが必要とされていない場合のみ)ペアリングがユーザーの入力なしに続けることができます:
@Override
public void onReceive(Context context, Intent intent) {
if(intent.getAction().equals(BluetoothDevice.ACTION_PAIRING_REQUEST)) {
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
device.setPairingConfirmation(true);
}
}
SDKを再構築し、定数およびメソッドへのアクセスを取得するために、新しいバージョンに対して自分のコードをコンパイルする必要がありますダイアログボックスを無効にするには、/ systemパーティションのSettings.apkを置き換えます。あなたはおそらくシステムアプリとして実行する必要があるかもしれないが、私はそうは思わない。
私は同じ問題を抱えています。私はdevice.cancelPairingUserInput();を呼び出してユーザの入力なしでダイアログを閉じることができます。 device.setPairingConfirmation(true); BluetoothDevice.ACTION_BOND_STATE_CHANGEDアクションがBluetoothDevice.BOND_BONDING状態で受信された後でなければ、ダイアログが短時間表示されて終了します。 –