3

这就是我目前的做法,但它只是强制关闭应用程序。

在第一个活动中

Intent myIntent = new Intent(Input.this, results.class);
    myIntent.putExtra("perfect", rig);
    startActivity(myIntent);`

我想转移到的活动

    Boolean lovers = getIntent().getExtras().getBoolean("perfect");
4

3 回答 3

5

正如文档所说,功能是getBooleanExtra

Boolean lovers = getIntent().getExtras().getBooleanExtra("perfect");
于 2012-12-10T01:10:09.410 回答
3

我不确定接受的答案::但我认为应该是

Boolean lovers = getIntent().getExtras().getBoolean("perfect");
于 2014-07-15T16:12:32.017 回答
1

您可以在发送方尝试此操作:

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");
于 2015-07-20T10:28:03.207 回答