Decode base64 string in Java using APIs JDK 8: java util base64.
An example to write base64 string to file in your file system environment.
Decode base64 string in Java using APIs JDK 8: java util base64.
An example to write base64 string to file in your file system environment.
Inter-workings JavaScript and Java Layer: use Clipboard Manager APIs directly in WebView component of Android library:
// no permission require in your manifest file of Android project... // start code @SuppressLint({"SetJavaScriptEnabled","JavascriptInterface"}) public class MainActivity extends Activity { public WebView webView; ClipboardManager myClipboard; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // source activity_main.xml webView = (WebView) findViewById(R.id.webview); webView.getSettings().setJavaScriptEnabled(true); webView.addJavascriptInterface(new WebAppInterface(this), "Android"); webView.setWebViewClient(new WebViewClient()); // important set Web Chrome Client webView.setWebChromeClient(new WebChromeClient()); webView.loadUrl(url); //local or remote } // final class to add in Web App final class WebAppInterface { Context mContext; /** Instantiate the interface and set the context */ WebAppInterface(Context c) { mContext = c; } /** Interface to use in web application */ @TargetApi(Build.VERSION_CODES.HONEYCOMB) @SuppressLint("NewApi") @JavascriptInterface public void copyToClipboard(String text) { try { myClipboard = (ClipboardManager)getSystemService(CLIPBOARD_SERVICE); ClipData myClip; myClip = ClipData.newPlainText("text", text); myClipboard.setPrimaryClip(myClip); Toast.makeText(getApplicationContext(), "Text Copied",Toast.LENGTH_SHORT).show(); } catch (Exception e) { Toast.makeText(getApplicationContext(), "Copy failed: " + e.toString(), Toast.LENGTH_SHORT).show(); } } } } // Now open html file in www folder of you Android project
A useful snippet HTML5 hybrid app for Android, using the method addJavascriptInterface to save and write file in external storage:
// write storage permission in your manifest file of Android project// start code @SuppressLint({"SetJavaScriptEnabled","JavascriptInterface"}) public class MainActivity extends Activity { public WebView webView; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // source activity_main.xml webView = (WebView) findViewById(R.id.webview); webView.getSettings().setJavaScriptEnabled(true); webView.addJavascriptInterface(new WebAppInterface(this), "Android"); webView.setWebViewClient(new WebViewClient()); // important set Web Chrome Client webView.setWebChromeClient(new WebChromeClient()); webView.loadUrl(url); //local or remote } // final class for save and write file in external storage final class WebAppInterface { Context mContext; /** Instantiate the interface and set the context */ WebAppInterface(Context c) { mContext = c; } public void writeToFile(String data, String filename, String tag) { try { File root = android.os.Environment.getExternalStorageDirectory(); File dir = new File (root.getAbsolutePath() + "/foldercustom"); dir.mkdirs(); File file = new File(dir, filename); FileOutputStream f = new FileOutputStream(file); PrintWriter pw = new PrintWriter(f); pw.println(data); pw.flush(); pw.close(); f.close(); } catch (IOException e) { Log.e(tag, "File write failed: " + e.toString()); } } } } // Now open html file in www folder ...
Uno dei framework che ha maggiormente attirato la mia attenzione in questi ultimi mesi รจ ZK. Con ZK puoi sviluppare applicazioni JEE web oriented RIA in maniera molto rapida, addirittura senza conoscere in maniera approfondita javascript e ajax. Il plugin del framework riservato ad Eclipse contiene un pannello GUI per il drag&drop degli oggetti e un Visual Editor per un’immediata anteprima dell’interfaccia grafica, con pochi script e una base dati xml puoi ottenere senza molta fatica un prodotto davvero interessante. Il sito del progetto contiene innumerevoli esempi arricchiti da una vasta documentazione e sourcecode per apprendere le basi e gli elementi intermedi e avanzati di questo impressionante framework destinato allo sviluppo di applicazioni web client e server su piattaforma apache tomcat o affini, con un impiego prevalente di ajax.