2015-12-21 33 views

回答

2

此行提出了一个“启用蓝牙”行动给用户。所以你在这里设置你的意图的行动。

Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); 

这条线被设置结果回来通过ID REQUEST_ENABLE_BT,这仅仅是你在你的本地类定义一个int。这可以是任何事情。它不必被称为REQUEST_ENABLE_BT ...你可以传入任何int,然后在获得结果时进行筛选。

startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT); 
在活动

所以这是接受的结果,它看起来是这样的:

protected void onActivityResult (int requestCode, int resultCode, Intent data) { 
    //int requestCode would equal REQUEST_ENABLE_BT in your case 
    //so you would test to make sure this is the result you want by testing 
    //to see if requestCode == REQUEST_ENABLE_BT 
} 
+0

我怎么看requestcode,resultCode为和数据(意向)的值,如果我想在Android中看到,如何打印奥尔烤面包。 –

+0

您可以使用'Log.d()'将值输出到控制台。 – NoChinDeluxe

+0

你的工作很感激。 –

相关问题