Android app on Webview
Released: Clouds Of Thought Android App
I was thinking to have a mobile app for my website - just because I can! Also, given my history of writing blogs every few weeks and being super lazy to even post it, I did not want to add another layer of work to do mobile releases whenever I post a blog.
Finally I released my Clouds of Thought app on Android - yay! :-)
Challenges
With maintainence being the biggest concern for me, I decided to settle for a webview. I implemented a simple caching into my webview and it worked insanely well. Posting some code snippets for reference:
Initializing a WebView in layout file:
WebView settings in main activity:
//private WebView siteWebview; // outside the onCreate(..) method siteWebview = (WebView) findViewById(R.id.siteWebview); WebSettings siteWebviewSettings = siteWebview.getSettings(); siteWebviewSettings.setJavaScriptEnabled(true); siteWebviewSettings.setLoadWithOverviewMode(true); siteWebviewSettings.setJavaScriptCanOpenWindowsAutomatically(false); siteWebviewSettings.setCacheMode(WebSettings.LOAD_DEFAULT); siteWebview.loadUrl("https://vishwarajanand.com/blog/"); siteWebview.setWebViewClient(new WebViewClient()); Implemented navigation for webview:
if(siteWebview != null && siteWebview.canGoBack()){ siteWebview.goBack(); } else{ super.onBackPressed(); }
I felt it was straightforward to implement and does not have any dependency on new blogs posted. Having a simple website mirror in my app works just fine for my usecases.
I felt it would be super awesome to have following features - which honestly I am still searching and it didn’t seem to be supported out of the box:
- Deeplinking to popular apps by default
- Filtering out web URLs which I do not want to allow - currently this app is just like a appified browser
I have hosted the sources on a private GitHub repo because it holds keys to upload the app to playstore too :-P , but for quick mental model check out some screenshots below:
TECH
java app android