-
Notifications
You must be signed in to change notification settings - Fork 85
08 Native applications
CraigD edited this page Oct 12, 2021
·
2 revisions
Material can send status updates, current toolbar colors, and active player id,
to native Android (and iOS?) applications. To enable this in material, pass the
nativeStatus, nativeColors, and nativePlayer query parameters, e.g.:
http://<yourserver>:9000/material/?nativeColors&nativePlayer&nativeStatus
Your Android app then needs something like the following:
public class MainActivity extends AppCompatActivity {
...
@Override
protected void onCreate(Bundle savedInstanceState) {
....
webView.loadUrl("http://<yourserver>:9000/material/?native");
webView.addJavascriptInterface(this, "NativeReceiver");
}
@JavascriptInterface
public void updateStatus(String status){
// 'status' is JSON string
}
@JavascriptInterface
public void updatePlayer(String playerId){
}
@JavascriptInterface
public void updateToolbarColors(String topColor, String bottomColor){
}
}