我使用这个应用程序作为一个框架,并试图将对象传递到我自己的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
图像。
我感谢所有帮助。