I have a native android app with 2 Activities.
1.- Main.java: contains a webview where a web POS is displayed with url: www.posWeb.com
2.- Camera.java: this activity sends a barcode reader to scan the products that are going to be searched in inventory or added to the cart.
The idea that I have is to send the bar code read from Camera.java to the Main, via the following code
Intent i = new Intent(getApplicationContext(),Main.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
i.putExtra("codeBar",rawResult.getText());
startActivity(i);
finish();
But the problem I have is that I need the webview to load a url depending on whether the application was started or if it came back from Camera.java
webView.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
}
});
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setDomStorageEnabled(true);
webView.setVerticalScrollBarEnabled(false);
webView.setHorizontalScrollBarEnabled(false);
Currently I am handling it in the following way:
if(getIntent().hasExtra("codeBar")) //el extra que envie desde Camera.java
webView.loadUrl(url+getIntent().getStringExtra("codeBar"));
else
webView.loadUrl(url);
Any suggestions?