Example usage for android.view Window FEATURE_INDETERMINATE_PROGRESS

List of usage examples for android.view Window FEATURE_INDETERMINATE_PROGRESS

Introduction

In this page you can find the example usage for android.view Window FEATURE_INDETERMINATE_PROGRESS.

Prototype

int FEATURE_INDETERMINATE_PROGRESS

To view the source code for android.view Window FEATURE_INDETERMINATE_PROGRESS.

Click Source Link

Document

Flag for indeterminate progress.

Usage

From source file:com.tonyandr.caminoguideoff.map.MapActivity.java

/**
 * Called when the activity is first created.
 *///from  ww w . j  a  v  a  2  s  .c o m
@Override
public void onCreate(final Bundle savedInstanceState) {
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    super.onCreate(savedInstanceState);

    this.setContentView(R.layout.activity_map);

    //        mStatusText = (TextView) findViewById(R.id.status_text);
    //        mCheckLicenseButton = (Button) findViewById(R.id.check_license_button);
    //        mCheckLicenseButton.setOnClickListener(new View.OnClickListener() {
    //            public void onClick(View view) {
    //                doCheck();
    //            }
    //        });
    mHandler = new Handler();
    // Try to use more data here. ANDROID_ID is a single point of attack.
    String deviceId = Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID);
    // Library calls this when it's done.
    mLicenseCheckerCallback = new MyLicenseCheckerCallback();
    // Construct the LicenseChecker with a policy.
    mChecker = new LicenseChecker(this,
            new ServerManagedPolicy(this, new AESObfuscator(SALT, getPackageName(), deviceId)),
            BASE64_PUBLIC_KEY);

    mPrefs = getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);

    if (!mPrefs.contains(KEY_LICENSE)) {
        if (isNetworkAvailable()) {
            doCheck();
        }
    }

    settings = PreferenceManager.getDefaultSharedPreferences(this);//get the preferences that are allowed to be given
    //set the listener to listen for changes in the preferences
    toolbar = (Toolbar) findViewById(R.id.app_bar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayShowHomeEnabled(true);

    NavigationDrawerLayout drawerFragment = (NavigationDrawerLayout) getFragmentManager()
            .findFragmentById(R.id.fragment_nav_drawer);
    drawerFragment.setUp(R.id.fragment_nav_drawer, (DrawerLayout) findViewById(R.id.drawer_layout), toolbar);

    fm = this.getFragmentManager();

    checkGPS();
}

From source file:com.scigames.slidegame.Registration2RFIDActivity.java

/** Called with the activity is first created. */
@Override/*from  w w w . jav a 2  s .  c  o m*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.d(TAG, "super.OnCreate");
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
    Intent i = getIntent();
    Log.d(TAG, "getIntent");
    visitIdIn = i.getStringExtra("visitId");
    studentIdIn = i.getStringExtra("studentId");

    firstNameIn = i.getStringExtra("fName");
    lastNameIn = i.getStringExtra("lName");
    //classIdIn = i.getStringExtra("mClass");
    //passwordIn = i.getStringExtra("mPass");
    Log.d(TAG, "...getStringExtra:");
    //Log.d(TAG,firstNameIn+lastNameIn);

    // Inflate our UI from its XML layout description.
    setContentView(R.layout.registration2_rfid);
    Log.d(TAG, "...setContentView: registration2_rfid");

    // Find the text editor view inside the layout, because we
    // want to do various programmatic things with it.
    braceletId = (EditText) findViewById(R.id.bracelet_id);
    /* to hide the keyboard on launch, then open when tap in firstname field */
    Log.d(TAG, "...braceletId EditText set");
    braceletId.setInputType(InputType.TYPE_NULL);
    Log.d(TAG, "...setInputType");
    braceletId.setOnTouchListener(new View.OnTouchListener() {
        //@Override
        public boolean onTouch(View v, MotionEvent event) {
            braceletId.setInputType(InputType.TYPE_CLASS_TEXT);
            braceletId.onTouchEvent(event); // call native handler
            return true; // consume touch even
        }
    });
    //firstName = (EditText) findViewById(R.id.first_name);
    //lastName = (EditText) findViewById(R.id.last_name);
    //password = (EditText) findViewById(R.id.password);
    Log.d(TAG, "...instantiateEditTexts");

    //        Log.d(TAG,"firstNameIn:");
    //        Log.d(TAG,firstNameIn);
    //        Log.d(TAG,"lastNameIn:");
    //        Log.d(TAG,lastNameIn);

    //set info to what we know already
    //lastName.setText(lastNameIn);
    // Log.d(TAG,"...lastName.setText");
    //firstName.setText(firstNameIn);
    // Log.d(TAG,"...firstName.setText");

    //display name in greeting sentence
    Resources res = getResources();
    TextView greets = (TextView) findViewById(R.id.greeting);
    Log.d(TAG, "...TextView greets find greeting");
    greets.setText(String.format(res.getString(R.string.greeting), firstNameIn, lastNameIn));
    Log.d(TAG, greets.toString());
    Log.d(TAG, "...Greetings");

    // Hook up button presses to the appropriate event handler.
    ((Button) findViewById(R.id.back)).setOnClickListener(mBackListener);
    ((Button) findViewById(R.id.continue_button)).setOnClickListener(mContinueButtonListener);
    ((Button) findViewById(R.id.scan)).setOnClickListener(mScanButtonListener);
    Log.d(TAG, "...instantiateButtons");

    task.setOnResultsListener(this);
}

From source file:com.pcinpact.ListeArticlesActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

    // On dfinit la vue
    setContentView(R.layout.liste_articles);
    // On rcupre les lments
    monListView = (ListView) this.findViewById(R.id.listeArticles);
    monSwipeRefreshLayout = (SwipeRefreshLayout) this.findViewById(R.id.swipe_container);
    headerTextView = (TextView) findViewById(R.id.header_text);

    setSupportProgressBarIndeterminateVisibility(false);

    // onRefresh/*from   w w  w  .j a va 2s . co m*/
    monSwipeRefreshLayout.setOnRefreshListener(new OnRefreshListener() {
        @Override
        public void onRefresh() {
            telechargeListeArticles();
        }
    });

    monItemsAdapter = new ItemsAdapter(this, mesArticles);
    monListView.setAdapter(monItemsAdapter);
    monListView.setOnItemClickListener(this);

    // On active le SwipeRefreshLayout uniquement si on est en haut de la listview
    monListView.setOnScrollListener(new AbsListView.OnScrollListener() {
        @Override
        public void onScrollStateChanged(AbsListView view, int scrollState) {
        }

        @Override
        public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
            int topRowVerticalPosition;

            if (monListView == null || monListView.getChildCount() == 0) {
                topRowVerticalPosition = 0;
            } else {
                topRowVerticalPosition = monListView.getChildAt(0).getTop();
            }
            monSwipeRefreshLayout.setEnabled(topRowVerticalPosition >= 0);
        }
    });

    // J'active la BDD
    monDAO = DAO.getInstance(getApplicationContext());
    // Je charge mes articles
    mesArticles.addAll(monDAO.chargerArticlesTriParDate());
    // Mise  jour de l'affichage
    monItemsAdapter.updateListeItems(prepareAffichage());

    // Message d'accueil pour la premire utilisation
    final SharedPreferences mesPrefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    // Est-ce la premiere utilisation de l'application ?
    Boolean premiereUtilisation = mesPrefs.getBoolean(getString(R.string.idOptionPremierLancementApplication),
            getResources().getBoolean(R.bool.defautOptionPremierLancementApplication));

    // Si premire utilisation : on affiche un disclaimer
    if (premiereUtilisation) {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        // Titre
        builder.setTitle(getResources().getString(R.string.app_name));
        // Contenu
        builder.setMessage(getResources().getString(R.string.disclaimerContent));
        // Bouton d'action
        builder.setCancelable(false);
        builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int id) {
                // Enregistrement que le message a dj t affich
                Editor editor = mesPrefs.edit();
                editor.putBoolean(getString(R.string.idOptionPremierLancementApplication), false);
                editor.commit();

                // Affichage de l'cran de configuration de l'application
                Intent intentOptions = new Intent(getApplicationContext(), OptionsActivity.class);
                startActivity(intentOptions);
            }
        });
        // On cre & affiche
        builder.create().show();

        // Lancement d'un tlchargement des articles
        telechargeListeArticles();
    }
}

From source file:fyp.samoleary.WildlifePrototype2.NavDrawer.NavDrawer.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    setContentView(R.layout.activity_main);
    isConnected = new GetConnectivityStatus();

    try {/*  w  w  w.java 2s. com*/
        app_ver = this.getPackageManager().getPackageInfo(this.getPackageName(), 0).versionName;
    } catch (PackageManager.NameNotFoundException e) {
        Log.v(LocationUtils.APPTAG, e.getMessage());
    }

    if (savedInstanceState == null) {
        selectItem(-1, -1);
    }
    Log.d(LocationUtils.APPTAG, "onCreate");

}

From source file:net.gaast.giggity.ChooserActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    //this.setTheme(android.R.style.Theme_Holo);

    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    requestWindowFeature(Window.FEATURE_PROGRESS);

    /*//test stuff//  ww w  .  j  a  v a  2 s  . c  o m
    Vibrator v = (Vibrator)getSystemService(Context.VIBRATOR_SERVICE);
    long[] pattern = {  };
    v.vibrate(pattern, -1);
    */

    Giggity app = (Giggity) getApplication();
    db = app.getDb();
    pref = PreferenceManager.getDefaultSharedPreferences(app);

    refreshSeed(false);

    list = new ListView(this);
    list.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapter, View view, int position, long id) {
            DbSchedule item = (DbSchedule) lista.getItem(position);
            if (item != null) {
                openSchedule(item, false);
            }
        }
    });
    list.setLongClickable(true);
    list.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {
        @Override
        public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
            AdapterContextMenuInfo mi = (AdapterContextMenuInfo) menuInfo;
            DbSchedule sched = (DbSchedule) lista.getItem((int) mi.id);
            if (sched != null) {
                menu.setHeaderTitle(sched.getTitle());
                menu.add(ContextMenu.NONE, 0, 0, R.string.refresh);
                menu.add(ContextMenu.NONE, 3, 0, R.string.unhide);
                menu.add(ContextMenu.NONE, 1, 0, R.string.remove);
                menu.add(ContextMenu.NONE, 2, 0, R.string.show_url);
            }
        }
    });

    /* Filling in the list in onResume(). */
    refresher = new SwipeRefreshLayout(this);
    refresher.setOnRefreshListener(this);
    refresher.addView(list);

    LinearLayout cont = new LinearLayout(this);
    cont.setOrientation(LinearLayout.VERTICAL);
    cont.addView(refresher, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1));

    setContentView(cont);
}

From source file:com.scigames.registration.LoginActivity.java

/** Called with the activity is first created. */
@Override//from  w w  w  . ja va  2  s .  com
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
    //getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION );
    // View v = findViewById(R.layout.login_page);
    // v.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); 
    //Window w = this.getWindow(); // in Activity's onCreate() for instance
    //w.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
    //        WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.login_page);
    Log.d(TAG, "super.OnCreate");
    // Inflate our UI from its XML layout description.       
    //        Intent i = getIntent();
    //        if (i.hasExtra("token")){
    //           setContentView(R.layout.login_page);
    //        } else {
    //           setContentView(R.layout.no_device);
    //        }
    lastName = (EditText) findViewById(R.id.last_name);
    password = (EditText) findViewById(R.id.password);
    classId = (EditText) findViewById(R.id.class_id);
    firstName = (EditText) findViewById(R.id.first_name);
    /* to hide the keyboard on launch, then open when tap in firstname field */
    //firstName.setActivated(false);
    //firstName.setSelected(false);
    firstName.setCursorVisible(false);
    firstName.setInputType(InputType.TYPE_NULL);
    firstName.setOnTouchListener(new View.OnTouchListener() {
        //@Override
        public boolean onTouch(View v, MotionEvent event) {
            firstName.setInputType(InputType.TYPE_TEXT_VARIATION_PERSON_NAME);
            firstName
                    .setInputType(InputType.TYPE_TEXT_FLAG_CAP_WORDS | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
            firstName.setCursorVisible(true);
            firstName.onTouchEvent(event); // call native handler
            return true; // consume touch even
        }
    });

    //for faster testing:
    //        firstName.setText("joseph7");
    //        lastName.setText("christopher");
    //        password.setText("qweasd");
    //        classId.setText("66");
    //        
    // Hook up button presses to the appropriate event handler.
    ((Button) findViewById(R.id.login_button)).setOnClickListener(mLogInListener);
    ((Button) findViewById(R.id.register)).setOnClickListener(mRegisterListener);

    //set listener
    task.setOnResultsListener(this);

    alertDialog = new AlertDialog.Builder(LoginActivity.this).create();
    // Setting Dialog Title
    alertDialog.setTitle("Login Failed");
    // Setting Dialog Message
    alertDialog.setMessage("Welcome to AndroidHive.info");
    // Setting Icon to Dialog
    //alertDialog.setIcon(R.drawable.tick);

    alertDialog.setButton(RESULT_OK, "OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            // Write your code here to execute after dialog closed
            Toast.makeText(getApplicationContext(), "Check your login info!", Toast.LENGTH_SHORT).show();
        }
    });

    Typeface ExistenceLightOtf = Typeface.createFromAsset(getAssets(), "fonts/Existence-Light.ttf");
    Typeface Museo300Regular = Typeface.createFromAsset(getAssets(), "fonts/Museo300-Regular.otf");
    Typeface Museo500Regular = Typeface.createFromAsset(getAssets(), "fonts/Museo500-Regular.otf");
    Typeface Museo700Regular = Typeface.createFromAsset(getAssets(), "fonts/Museo700-Regular.otf");

    //       TextView welcome = (TextView)findViewById(R.id.welcome);
    TextView notascigamersentence = (TextView) findViewById(R.id.notascigamersentence);
    //       setTextViewFont(ExistenceLightOtf, welcome);
    setTextViewFont(Museo500Regular, notascigamersentence);
    setEditTextFont(Museo500Regular, firstName, lastName, password, classId);

    login = (Button) findViewById(R.id.login_button);
    register = (Button) findViewById(R.id.register); /* out for now */
    setButtonFont(ExistenceLightOtf, login, register);
    setButtonFont(Museo500Regular, register);

    //        if (getIntent().getBooleanExtra("EXIT", false)) {
    //            finish();
    //        }

}

From source file:de.stadtrallye.rallyesoft.ConnectionAssistantActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Title and Content
    supportRequestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

    setTitle(R.string.connection_assistant);
    //      setContentView(R.layout.connection_assistant);

    ActionBar ab = getSupportActionBar();
    ab.setDisplayHomeAsUpEnabled(true);//from www .  ja va 2 s  . co  m
    ab.setDisplayShowTitleEnabled(true);

    Storage.aquireStorage(getApplicationContext(), this);

    if (savedInstanceState != null) {
        step = savedInstanceState.getInt(Std.STEP);
        server = Server.load(savedInstanceState.getString(Std.SERVER));
        name = savedInstanceState.getString(Std.NAME);
    }

    //Create FragmentHandlers
    steps = new ArrayList<FragmentHandler<?>>();
    steps.add(new FragmentHandler<AssistantServerFragment>("server", AssistantServerFragment.class));
    steps.add(new FragmentHandler<AssistantGroupsFragment>("groups", AssistantGroupsFragment.class));
    steps.add(new FragmentHandler<AssistantAuthFragment>("auth", AssistantAuthFragment.class));
    steps.add(new FragmentHandler<AssistantCompleteFragment>("complete", AssistantCompleteFragment.class));

    getLoaderManager().initLoader(0, null, this);
}

From source file:com.arantius.tivocommander.ToDo.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (MindRpc.init(this, null)) {
        return;//from w w  w .j a  va2  s  . co  m
    }

    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    setContentView(R.layout.list_todo);
    setTitle("To Do List");

    mListAdapter = new ShowsAdapter(this);
    ListView lv = getListView();
    lv.setAdapter(mListAdapter);
    lv.setOnItemClickListener(mOnClickListener);
    lv.setLongClickable(true);
    lv.setOnItemLongClickListener(this);

    mDetailCallback = new MindRpcResponseListener() {
        public void onResponse(MindRpcResponse response) {
            setProgressIndicator(-1);

            String itemId = "recording";
            final JsonNode items = response.getBody().path(itemId);

            ArrayList<Integer> slotMap = mRequestSlotMap.get(response.getRpcId());

            for (int i = 0; i < items.size(); i++) {
                int pos = slotMap.get(i);
                JsonNode item = items.get(i);
                mShowData.set(pos, item);
                mShowStatus.set(pos, ShowStatus.LOADED);
            }

            mRequestSlotMap.remove(response.getRpcId());
            mListAdapter.notifyDataSetChanged();
        }
    };

    mIdSequenceCallback = new MindRpcResponseListener() {
        public void onResponse(MindRpcResponse response) {
            JsonNode body = response.getBody();

            setProgressIndicator(-1);

            mShowIds = (ArrayNode) body.findValue("objectIdAndType");
            if (mShowIds == null)
                return;

            for (int i = 0; i < mShowIds.size(); i++) {
                mShowData.add(null);
                mShowStatus.add(ShowStatus.MISSING);
            }
            mListAdapter.notifyDataSetChanged();
        }
    };

    startRequest();
}

From source file:app.wz.MainActivity.java

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    self = this;//from   www  .  j  av  a 2 s.  co  m

    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    setProgressBarIndeterminateVisibility(false);

    setContentView(R.layout.layout_main);

    // initialize your android device sensor capabilities
    mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);

    powerManager = (PowerManager) getSystemService(POWER_SERVICE);
    wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "MyWakelockTag");

    wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
    lock = wifiManager.createWifiLock(WifiManager.WIFI_MODE_FULL, "LockTag");

    prefs = PreferenceManager.getDefaultSharedPreferences(this.getApplicationContext());

    textScroll = (ScrollView) findViewById(R.id.textScroll);
    textRead = (TextView) findViewById(R.id.textRead);

    commStatus = (TextView) findViewById(R.id.commStatus);
    pingStatus = (TextView) findViewById(R.id.pingStatus);
    inputCmd = (EditText) findViewById(R.id.inputCmd);
    inputVal = (EditText) findViewById(R.id.inputVal);

    gb = (GlobalApp) getApplication();

    gb.bt = new BluetoothSPP(this);
    bt = gb.bt;
    gb.arduino = new ArduinoFirmata(this, bt);
    arduino = gb.arduino;

    gb.neuro = new NeuroInterface(prefs, gb);

    neuro = gb.neuro;

    if (prefs.getBoolean("autoload", false)) {
        if (neuro.loadWeights(prefs.getString("last_save", ""))) {
            textRead.append("Restored Weights at Step " + neuro.count + "\n");
            textScroll.fullScroll(View.FOCUS_DOWN);
        }
    }

    if (!bt.isBluetoothAvailable()) {
        Toast.makeText(getApplicationContext(), "Bluetooth is not available", Toast.LENGTH_SHORT).show();
        finish();
    }

    bt.setOnDataReceivedListener(new OnDataReceivedListener() {
        public void onDataReceived(byte[] data, String message) {
            gb.lastResponseBT = System.currentTimeMillis();
            arduino.processInput(data);
        }
    });

    bt.setBluetoothConnectionListener(new BluetoothConnectionListener() {
        public void onDeviceDisconnected() {

            haltNeuro();

            commStatus.setText("Status : Not Connected");
            menu.clear();
            getMenuInflater().inflate(R.menu.connection, menu);
        }

        public void onDeviceConnectionFailed() {
            commStatus.setText("Status : Connection Failed");
        }

        public void onDeviceConnected(String name, String address) {
            commStatus.setText("Status : Connected to " + name);
            menu.clear();
            getMenuInflater().inflate(R.menu.disconnection, menu);
        }
    });

    //        bt.setAutoConnectionListener(new BluetoothSPP.AutoConnectionListener() {
    //            public void onNewConnection(String name, String address) {
    //                Log.i("Check", "New Connection - " + name + " - " + address);
    //            }
    //
    //            public void onAutoConnectionStarted() {
    //                Log.i("Check", "Auto connection started");
    //            }
    //        });

    if (!bt.isBluetoothEnabled()) {
        Intent intent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
        startActivityForResult(intent, BluetoothState.REQUEST_ENABLE_BT);
    } else {
        if (!bt.isServiceAvailable()) {
            bt.setupService();
            bt.startService(BluetoothState.DEVICE_ANDROID);
            setup();
        }
    }

    refreshPing.start();
    neuroThread.start();

    new Thread() {
        public void run() {
            while (true) {
                try {
                    Thread.sleep(500);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                if (neuro.count > neuro.lastDisplay) {
                    neuro.lastDisplay = neuro.count;
                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            if (!neuro.halt) {
                                textRead.append(
                                        "P err:  " + (new DecimalFormat("0.000E0")).format(neuro.avg_error)
                                                + "    O err:  "
                                                + (new DecimalFormat("0.000E0")).format(neuro.avg_obj_error)
                                                + "    stp:  " + neuro.count + "\n");

                                textScroll.fullScroll(View.FOCUS_DOWN);
                            }
                        }
                    });
                }
            }
        }
    }.start();

    new Thread() {
        public void run() {
            while (true) {
                try {
                    Thread.sleep(10000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        if (textRead.length() > 20000)
                            textRead.setText("");
                    }
                });
            }
        }
    }.start();

}