我将此应用程序用作框架并尝试将对象传递给我自己的 UI Phone Call 。
但是当我尝试将我的对象放入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
in传递我的对象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
图像。
我很感激任何帮助。