【问题标题】:Setting up an Android Activity within Titanium在 Titanium 中设置 Android Activity
【发布时间】:2012-09-02 21:43:19
【问题描述】:

我正在尝试在 Android 设备上启用蓝牙。我已阅读 Android 文档,并且非常了解该过程是什么。但是,我更倾向于使用清单文件实际启动 Activity。这就是我到目前为止所做的......

我开发了一个包含几个类的 Android 模块:

  1. BluetoothModule // 扩展 KrollModule
  2. BluetoothSetup // 扩展 Activity

在 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>

模块编译得很好,但实际上并没有做任何事情。我担心我在这里错过了一个基本步骤,但我不确定它是什么。任何建议将不胜感激!

【问题讨论】:

    标签: java bluetooth titanium android-activity appcelerator


    【解决方案1】:

    想通了。在这里按照说明创建自定义:

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

    我删除了清单文件中额外的 Titanium 代码,它似乎可以正常工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-03-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-06
      • 2019-03-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多