getparcelableextra deprecated
时间: 2023-07-28 19:08:54 浏览: 67
Yes, the `getParcelableExtra` method is deprecated in newer versions of Android. Instead, you should use the `getParcelableExtra` method from the `Intent` class.
Here's an example of how you can retrieve a `Parcelable` extra from an intent using the updated method:
```java
Intent intent = getIntent();
YourParcelableClass parcelable = intent.getParcelableExtra("your_key");
```
Make sure to replace `"your_key"` with the actual key you used when putting the extra into the intent.
If you're targeting Android API level 30 or higher, you can also use the new `getParcelableExtraOrNull` method, which returns `null` if the extra is not found:
```java
Intent intent = getIntent();
YourParcelableClass parcelable = intent.getParcelableExtraOrNull("your_key");
```
Remember to update your code accordingly to use the recommended methods and avoid using deprecated ones.
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)