0

I have implemented Chronometer to show call duration during Video and Audio call. Chronometer increase by one during the video call, but during the video call, it sometimes increases by one or two.

Start Chronometer after call connected

timeChronometer.setBase(SystemClock.elapsedRealtime()); 
timeChronometer.start();

Layout

<LinearLayout
    android:id="@+id/call_type"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:orientation="horizontal"
    android:paddingLeft="16.0dip"
    android:paddingTop="23.0dip"
    android:paddingRight="16.0dip">

    <TextView

        android:id="@+id/voip_call_label"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:drawableStart="@drawable/calllogo"
        android:drawableLeft="@drawable/calllogo"
        android:drawablePadding="6dp"
        android:text="@string/video_call_label"
        android:textColor="#99ffffff"
        android:textSize="14.0sp" />

</LinearLayout>


<FrameLayout
    android:id="@+id/caller_contact_photo"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:animateLayoutChanges="true"
    android:paddingTop="28dip">


    <ImageView
        android:id="@+id/contact_photo"
        android:layout_width="90.0dip"
        android:layout_height="90.0dip"
        android:layout_gravity="center"
        android:src="@drawable/ic_circle_img"
        android:scaleType="fitCenter" />

    <android.support.v7.widget.AppCompatImageView
        android:id="@+id/whatsapp_icon"
        android:layout_width="20.0dip"
        android:layout_height="20.0dip"
        android:layout_gravity="bottom|center|right"
        android:layout_marginEnd="4dp"
        android:layout_marginRight="4dp"
        android:layout_marginBottom="4dp"
        android:rotation="-10.0"
        android:src="@drawable/icon"
        android:visibility="gone" />
</FrameLayout>

<LinearLayout
    android:id="@+id/name_layout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:paddingLeft="16.0dip"
    android:paddingTop="20.0dip"
    android:paddingRight="16.0dip">

    <TextView
        android:id="@+id/name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ellipsize="end"
        android:paddingBottom="20.0dip"
        android:singleLine="true"
        android:text="Mukesh Singh"
        android:textColor="@android:color/white"
        android:textSize="26.0sp" />
</LinearLayout>

<TextView
    android:id="@+id/call_status"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:lineSpacingMultiplier="1.5"
    android:paddingLeft="12.0dp"
    android:paddingRight="12.0dp"
    android:paddingBottom="20.0dp"
    android:text="INCOMING"
    android:textColor="#99ffffff"
    android:textSize="14.0sp" />
 </LinearLayout>

<RelativeLayout
android:id="@+id/top_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:visibility="visible">

<ImageButton
    android:id="@+id/top_minimize_btn"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_gravity="center"
    android:background="@drawable/voip_btn_background"
    android:contentDescription="@string/voip_call_goto_chat_description"
    android:padding="18.0dip"
    android:src="@drawable/call_minimize"
    android:visibility="gone" />

<Chronometer
    android:id="@+id/timeChronometer"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
  android:layout_centerHorizontal="true"
    android:layout_gravity="center"
    android:gravity="center"
    android:paddingStart="18.0dp"
    android:paddingTop="24.0dp"
    android:paddingEnd="18.0dp"
    android:textColor="#99ffffff"

    android:textSize="14.0sp"
    android:visibility="gone" />
   </RelativeLayout>
   </RelativeLayout >
4

0 に答える 0