Display Snackbar when message is received
This commit is contained in:
@@ -12,6 +12,8 @@ import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.ToggleButton;
|
||||
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
@@ -22,6 +24,9 @@ public class MainActivity extends AppCompatActivity {
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String msg = intent.getStringExtra("STATE");
|
||||
Log.i(TAG, "Received " + msg);
|
||||
View contextView = findViewById(R.id.toggleButton);
|
||||
Snackbar.make(contextView, "Received " + msg, Snackbar.LENGTH_LONG)
|
||||
.show();
|
||||
stateButton.setChecked(!msg.equals("OFF"));
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user