我有一个关于意图另一个Activity的问题并带有String。
我指的是#34; DeviceScanActivity"示例代码,我找到了这个:
final Intent intent = new Intent(this, DeviceControlActivity.class);
intent.putExtra(DeviceControlActivity.EXTRAS_DEVICE_ADDRESS,device.getAddress());
startActivity(intent);
然后在" DeviceControlActivity"示例代码,我发现:
final Intent intent = getIntent();
mDeviceAddress = intent.getStringExtra(EXTRAS_DEVICE_ADDRESS);
mDeviceAddress将从DeviceScanActivity获取String。
现在我想将另一个Activity从DeviceControlActivity转向NewActivity, 所以在DeviceControlActivity中,我这样做:
final Intent intent = new Intent(this, NewActivity.class);
intent.putExtra(NewActivity.DEVICE_ADDRESS, EXTRAS_DEVICE_ADDRESS);
startActivity(intent);
在NewActivity中,我这样做:
final Intent intent = getIntent();
address = intent.getStringExtra(DEVICE_ADDRESS);
((TextView) findViewById(R.id.p1_device_address)).setText(address);
但是在NewActivity中,我只能看到" DEVICE_ADDRESS" ?
并非如此:B0:B4:48:BD:69:85
我想知道为什么,任何人都可以帮助我,我会非常感激,Tnanks。