Android Textview status is not changing when its relaunched/(minimize to open)

60 views Asked by At

I followed this to Create sample radio stream in android

Over there every thing is fine But When I minimize and re-open the app from notification or directly

The Text view status is not updating Until I click on any button

This the status code

@Override
protected void onResume() {
    super.onResume();
    mRadioManager.connect();
}

@Override
public void onRadioLoading() {
    runOnUiThread(new Runnable() {
        @Override
        public void run() {
            //TODO Do UI works here.
            mTextViewControl = (TextView) findViewById(R.id.textviewControl);
            mTextViewControl.setText("RADIO STATE : LOADING...");
            mTextViewControl.invalidate();
        }
    });
}

@Override
public void onRadioConnected() {

}

@Override
public void onRadioStarted() {
    runOnUiThread(new Runnable() {
        @Override
        public void run() {
            //TODO Do UI works here.
            mTextViewControl = (TextView) findViewById(R.id.textviewControl);
            mTextViewControl.setText("RADIO STATE : PLAYING...");
            mTextViewControl.invalidate();
        }
    });
}

@Override
public void onRadioStopped() {
    runOnUiThread(new Runnable() {
        @Override
        public void run() {
            //TODO Do UI works here
            mTextViewControl = (TextView) findViewById(R.id.textviewControl);
            mTextViewControl.setText("RADIO STATE : STOPPED.");
            mTextViewControl.invalidate();
        }
    });
}

Here I removed Default text(android:text="RADIO STATE : IDLE") from XML also

But still same issue. This is the full reference code

Update 1

Actually I have a Radio Player Notification service so when I click on the notification it will open the app from the notification its stating and stopping But when I open app It form the Notification the status of Textview is not working

I changed runOnUiThread(new Runnable() instead of mTextViewControl.post(new Runnable()

But still same issue

Please help me on this kind

1

There are 1 answers

1
Karthik Sridharan On

use runonuithread() instead of post()

@Override
public void onRadioStarted() {
    mTextViewControl = (TextView) findViewById(R.id.textviewControl);
    mTextViewControl.post(new Runnable() {
        @Override
        public void run() {
            mTextViewControl.setText("RADIO STATE : STOPPED.");
        }
    });
}