在Titanium中设置Android活动

时间:2012-09-10 02:15:33

标签: java bluetooth titanium android-activity appcelerator

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

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

  1. BluetoothModule //扩展KrollModule
  2. BluetoothSetup //扩展活动
  3. 在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>
    

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

1 个答案:

答案 0 :(得分:3)

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

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

我删除了清单文件中的额外代码Titanium drop,它似乎正在运行。

相关问题