2

I have an activity which calls functions which have Thread.Sleep calls and Handlers which do further processing of data i receive from a Bluetooth connection.

I want to show a loading progress bar animation while the handlers are being called. It may take from few minutes to several hours to completly process the data from Bluetooth device.

Hence i have declared a progress bar in the XML file and will set the progress view to "View.GONE" once processing of data is complete.

The problem is the loading animation is shown until my handler is called. Once the handler is called the loading animation is hung and is released back when all my handler calls are completed. Below is the XML and class file i am using

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="bottom"
    android:background="@drawable/bg"
    android:orientation="vertical"
    android:paddingBottom="40dp"
    android:paddingLeft="20dp"
    android:paddingRight="20dp">

    <RelativeLayout
        android:id="@+id/loadingPanel"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center" >

        <ProgressBar
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:indeterminate="true" />
    </RelativeLayout>

</LinearLayout>

Below is link to source code for the java file.

https://drive.google.com/file/d/0B7CcUOV3YOH7NUtNSXB1Nk5KbE0/view?usp=sharing

"MainDefine.penController.OpenFileTobyte(mFolderName, mFileName);" in function "downLoadDIPage" triggers the handlers defined in class.

I think the problem is, handler functions are being executed on the UI thread and hence its blocking the loading progress bar. I have tried starting the functions called from the handlers on new thread but that didn't solve my problem.

I am stuck with this issue and and is the only issue blocking my product release. Can any one please help me in fixing this issue.

Thanks in advance.

Abhinay
  • 75
  • 12

0 Answers0