Java 无法从捆绑包中检索Paint.Cap类型的数据
我到处寻找这个问题,但找不到任何答案 我正在通过这样的意图发送数据Java 无法从捆绑包中检索Paint.Cap类型的数据,java,android,android-intent,bundles,Java,Android,Android Intent,Bundles,我到处寻找这个问题,但找不到任何答案 我正在通过这样的意图发送数据 MainActivity.java Intent intent = new Intent(MainActivity.this, SecondActivity.class); intent.putExtra("key",Paint.Cap.SQUARE); startActivity(intent); 我的问题是检索它,我不知道使用哪种get方法,我也找不到任何在线来源告诉我 S
MainActivity.java
Intent intent = new Intent(MainActivity.this, SecondActivity.class);
intent.putExtra("key",Paint.Cap.SQUARE);
startActivity(intent);
我的问题是检索它,我不知道使用哪种get方法,我也找不到任何在线来源告诉我
SecondActivity.java
Bundle extras = getIntent().getExtras();
if(extras !=null)
{
if(extras.containsKey("key"))
{
Paint.Cap shape = //which method to use here?
}
}
如果它是如此愚蠢,请告诉我,我仍然是一个初学者,并尽我最大的努力找到自己的东西
谢谢。关键在于Paint.Cap是一个枚举,因此它实现了可序列化的接口
这意味着您调用了接受序列化的putExtra版本
要想再把它弄出来,你可以
Paint.Cap shape = (Paint.Cap) extras.getSerializable("key");
可能重复的