我正在使用this app作为框架,并试图将对象传递给我自己的UI电话。
但是当我尝试将对象放入myAdapter
时:
Call.putExtra("itemObject", items.get(position));
我收到一个BadParcelableException
错误:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.server.telecom/com.android.server.telecom.components.UserCallActivity}: android.os.BadParcelableException: ClassNotFoundException when unmarshalling: com.example.aliton.customphonecall.itemObject
问题:如何将对象传递给CallActivity
?
为了更清楚一点,我想通过Button
中的myAdapter
传递对象。
从下面可以看出,Button
轨道首先从myAdapter
到CallService
,在CallService
内部被称为CallActivity
。
然后我想可以将对象传递给CallService
,然后再次将对象传递给CallActivity
。
I/debinf Adapter: Requesting Call
I/debinf CallService: onCallAdded
I/debinf OngoingCall: call.getState() is 9
I/debinf CallService: starting CallActivity
I/debinf CallActivity: onCreate
I/debinf OngoingCall: state is 1
I/debinf OngoingCall: state is 4
这里是myAdapter
:
public class myAdapter extends BaseAdapter {
private ArrayList<itemObject> items;
private Context context;
public myAdapter(ArrayList<itemObject> items, Context context) {
this.items = items;
this.context = context;
}
@Override
public int getCount() {
return items.size();
}
@Override
public Object getItem(int position) {
return items.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.item_call, parent, false);
TextView mName = (TextView) view.findViewById(R.id.item_name);
TextView mId = (TextView) view.findViewById(R.id.item_id);
final TextView mPhone = (TextView) view.findViewById(R.id.item_phone);
ImageButton mCall = (ImageButton) view.findViewById(R.id.item_call);
mName.setText(items.get(position).getName());
mId.setText(items.get(position).getId());
mPhone.setText(items.get(position).getPhone());
mCall.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Uri uri = Uri.parse("tel:"+mPhone.getText().toString().trim());
Intent Call = new Intent(Intent.ACTION_CALL, uri);
Call.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Call.putExtra("itemObject", items.get(position));
Log.i("debinf Adapter", "Requesting Call");
context.startActivity(Call);
}
});
return view;
}
}
这是我的CallService
:
public class CallService extends InCallService {
@Override
public void onCallAdded(Call call) {
super.onCallAdded(call);
Log.i("debinf CallService", "onCallAdded");
new OngoingCallObject().setCall(call);
Log.i("debinf CallService", "starting CallActivity");
Intent CallAct = new Intent(this, CallActivity.class);
CallAct.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
CallAct.setData(call.getDetails().getHandle());
startActivity(CallAct);
//CallActivity.start(this, call);
}
@Override
public void onCallRemoved(Call call) {
super.onCallRemoved(call);
Log.i("debinf CallService", "onCallRemoved");
new OngoingCallObject().setCall(null);
}
}
我想用我的对象填充TextView
左上角的CallActivity
。
这是DialerAcitivity
张图片。
感谢您的帮助。