通话结束后,我正在阅读通话日志。如果通话已连接,则通话持续时间大于0。如果持续时间大于0,则在2天后为该号码安排下一个电话。如果通话持续时间为0,则在1天后为该号码安排下一个电话。
我的问题是当通话连接时,它被正确地安排了,但当通话未连接时,先前的文本显示出来。有时它是正确的,有时它不正确。
我从接收器打开此活动。请提供更好的解决方案。
以下是我的代码:
@Override
protected void onResume() {
/**
* this values only set when call maked from app then it w
* ill set auto filled some of filled in follow up
*
*/
if(flag!=null && flag.equalsIgnoreCase("Followup")/*&& state!=true*/){
if(SharedPrefs.getBoolean(this, SharedPrefs.PREFS_AUTH, SharedPrefs.
KEY_SCHEDULE_NEXT_FOLLOWUP, false))
{
findViewById(R.id.rl_followUp).setVisibility(View.VISIBLE);
} else {
findViewById(R.id.rl_followUp).setVisibility(View.GONE);
}
getCallDetails();
/*
String strDateFormat = "hh:mm a";
SimpleDateFormat sdf = new SimpleDateFormat(strDateFormat);
calendar=Calendar.getInstance();
*/
if(callDuration > 0){
tvDateText.setText(timeInMilies(2));
etFUComments.setText("Call is done");
} else {
tvDateText.setText(timeInMilies(1));
etFUComments.setText(getResources().
getString(R.string.call_not_connected_detail));
}
}
super.onResume();
}
private void getCallDetails() {
StringBuffer sb = new StringBuffer();
String strOrder = android.provider.CallLog.Calls.DATE + " DESC";
/* Query the CallLog Content Provider */
managedCursor = managedQuery(CallLog.Calls.CONTENT_URI, null,
null, null, strOrder);
int number = managedCursor.getColumnIndex(CallLog.Calls.NUMBER);
int type = managedCursor.getColumnIndex(CallLog.Calls.TYPE);
int date = managedCursor.getColumnIndex(CallLog.Calls.DATE);
duration = managedCursor.getColumnIndex(CallLog.Calls.DURATION);
sb.append("Call Log :");
if (managedCursor.moveToNext()) {
phNum = managedCursor.getString(number);
String callTypeCode = managedCursor.getString(type);
String strcallDate = managedCursor.getString(date);
callDate = new Date(Long.valueOf(strcallDate));
callDuration =Integer.parseInt(managedCursor.getString(duration));
String callType = null;
int callcode = Integer.parseInt(callTypeCode);
switch (callcode) {
case CallLog.Calls.OUTGOING_TYPE:
callType = "Outgoing";
break;
case CallLog.Calls.INCOMING_TYPE:
callType = "Incoming";
break;
case CallLog.Calls.MISSED_TYPE:
callType = "Missed";
break;
}
}
managedCursor.close();
}
public String timeInMilies(int day){
Date date=new Date();//(86400000*2)
long time= date.getTime();
DateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(time + (86400000 * day));
//etFUComments.setText(String.valueOf(formatter.format(calendar.getTime())));
return String.valueOf(formatter.format(calendar.getTime()));
}