这就是我目前的做法,但它只是强制关闭应用程序。
在第一个活动中
Intent myIntent = new Intent(Input.this, results.class);
myIntent.putExtra("perfect", rig);
startActivity(myIntent);`
我想转移到的活动
Boolean lovers = getIntent().getExtras().getBoolean("perfect");
这就是我目前的做法,但它只是强制关闭应用程序。
在第一个活动中
Intent myIntent = new Intent(Input.this, results.class);
myIntent.putExtra("perfect", rig);
startActivity(myIntent);`
我想转移到的活动
Boolean lovers = getIntent().getExtras().getBoolean("perfect");
正如文档所说,功能是getBooleanExtra
Boolean lovers = getIntent().getExtras().getBooleanExtra("perfect");
我不确定接受的答案::但我认为应该是
Boolean lovers = getIntent().getExtras().getBoolean("perfect");
您可以在发送方尝试此操作:
MyModel model = new MyModel();
//1. using constructor
Boolean blnObj1 = new Boolean(model.getBooleanStatus()); // This //getBooleanStatus will return 'boolean' value
//2. using valueOf method of Boolean class. This is a static method.
Boolean blnObj2 = Boolean.valueOf(model.getBooleanStatus());
}
Intent targetIntent = new Intent(MyCalass.this, TargetClass.class);
targetIntent.putExtra("STATUS", new Boolean(model.getBooleanStatus()));
targetIntent.putExtra("STATUS", Boolean.valueOf(model.getBooleanStatus()));
startActivity(targetIntent);
接收方:
Intent receiverIntent = getIntent().getBoolean("STATUS");