我将serializable
类型的对象通过BroadcastReceiver
到IntentService
的{{1}}传递。
此代码已分配给BroadcastReceiver
:
BroadcastReceiver
但是我的问题是,Android Studio说 @Override
public void onReceive(Context context, Intent intent) {
Log.d(TAG, "onReceive: Received Broadcast: " + intent + " from context: " + context);
RetrofitResponseProfile retrofitResponseProfile = intent.getSerializableExtra(NetworkService.NETWORK_RESPONSE_PROFILE);
}
对象不是来自retrofitRepsonseProfile
类型的对象。
有人可以帮助我,如何从serializable
中的serializable
接收IntentService
对象吗?
非常感谢!
答案 0 :(得分:3)
Your Class Should Be
Class RetrofitResponseProfile implements Serializable{
//Create Variables And Functions
}
And During Call
RetrofitResponseProfile retrofitResponseProfile = (RetrofitResponseProfile) intent.getSerializableExtra("Key0");
hope this may help you