import android.annotation.SuppressLint; import android.os.Bundle; import android.webkit.WebChromeClient; import android.webkit.WebResourceRequest; import android.webkit.WebView; import android.webkit.WebViewClient; import androidx.appcompat.app.AppCompatActivity; public class MainActivity extends AppCompatActivity { private WebView webView; private String symbol = "NASDAQ:AAPL"; // Default symbol (you can change this dynamically) @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); webView = findViewById(R.id.webView); setupWebView(); } @SuppressLint("SetJavaScriptEnabled") private void setupWebView() { webView.getSettings().setJavaScriptEnabled(true); webView.setWebViewClient(new WebViewClient()); webView.setWebChromeClient(new WebChromeClient()); // Load the HTML with the dynamic symbol String htmlData = "<html><body onload=\"loadChart('" + symbol + "');\">" + "<script type=\"text/javascript\" src=\"file:///android_asset/tradingview.html\"></script>" + "</body></html>"; webView.loadDataWithBaseURL("file:///android_asset/", htmlData, "text/html", "UTF-8", null); } }<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>TradingView Chart</title> </head> <body> <!-- TradingView Widget BEGIN --> <div class="tradingview-widget-container"> <div id="tradingview_dee8c"></div> <div class="tradingview-widget-copyright"> <a href="https://www.tradingview.com/" rel="noopener nofollow" target="_blank" rel="nofollow" > <span class="blue-text">Track all markets on TradingView</span> </a> </div> <script type="text/javascript" src="https://s3.tradingview.com/tv.js"></script> <script type="text/javascript"> function loadChart(symbol) { new TradingView.widget({ "autosize": true, "symbol": symbol, "interval": "D", "timezone": "Etc/UTC", "theme": "light", "style": "1", "locale": "en", "toolbar_bg": "#f1f3f6", "enable_publishing": false, "allow_symbol_change": true, "container_id": "tradingview_dee8c" }); } </script> </div> <!-- TradingView Widget END --> </body> </html>