3

Android デバイスで Bluetooth を有効にしようとしています。私は Android のドキュメントを読んで、プロセスが何であるかについてかなり良い考えを持っています。ただし、マニフェスト ファイルを使用して実際にアクティビティを起動するのはかなり面倒です。これは私がこれまでやってきたことです...

いくつかのクラスを持つ Android モジュールを開発しました。

  1. BluetoothModule // KrollModule を拡張します
  2. 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>

モジュールは問題なくコンパイルされますが、実際には何もしません。ここで基本的なステップを逃したのではないかと心配していますが、それが何であるかはわかりません. どんなアドバイスでも大歓迎です!

4

1 に答える 1

3

これを理解しました。ここの指示に従ってカスタムを作成してください:

https://wiki.appcelerator.org/display/guides/Maintaining+a+Custom+AndroidManifest.xml

マニフェスト ファイルに追加された Titanium ドロップの余分なコードを削除したところ、動作しているようです。

于 2012-09-10T15:41:42.357 に答える