Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
这是否可以在旋转时保存 AsyncTask 类对象并再次重用它。
public class MyTask extends AsyncTask<Void, Void, Integer> { }
任何好的解决方案。谢谢
使用onRetainNonConfigurationInstance()或保留的片段。
onRetainNonConfigurationInstance()
感谢您的回复,但 onRetainNonConfigurationInstance() 在 3.0 之后已弃用
那是因为他们建议您改用保留片段。如果您不使用片段,请使用onRetainNonConfigurationInstance().