Android デバイスで Bluetooth を有効にしようとしています。私は Android のドキュメントを読んで、プロセスが何であるかについてかなり良い考えを持っています。ただし、マニフェスト ファイルを使用して実際にアクティビティを起動するのはかなり面倒です。これは私がこれまでやってきたことです...
いくつかのクラスを持つ Android モジュールを開発しました。
- BluetoothModule // KrollModule を拡張します
- BluetoothSetup // アクティビティを拡張します
BluetoothSetup では、onCreate
メソッドは次のようになります。
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
connectBluetooth();
}
また、BluetoothSetup では、connectBluetooth() メソッドは次のようになります。
protected void connectBluetooth(){
// if statements to check if bluetooth is enabled/avail removed
Intent intentBluetooth = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(intentBluetooth, 0);
}
}
最後に、モジュールの timodule.xml に次を追加しました。
<activity android:label="@string/app_name" android:name="com.eyesore.bluetooth2.BluetoothSetup">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
モジュールは問題なくコンパイルされますが、実際には何もしません。ここで基本的なステップを逃したのではないかと心配していますが、それが何であるかはわかりません. どんなアドバイスでも大歓迎です!