Hello everybody! What you are seeing here is an Android app that shows a local html file inside a Web View. Then on top of the web view there is a button to save web view contents as a pdf file. Pdf file is saved...

Source Codes & Coding Tutorials
Hello everybody! What you are seeing here is an Android app that shows a local html file inside a Web View. Then on top of the web view there is a button to save web view contents as a pdf file. Pdf file is saved...
Now we are ready to add our html file inside assets folder. Create a folder named assets and put your html file there. Then build the app. You will see your app is running displaying that html page. This code is for html sample page...
The next step is to edit MainActivity.java file. Copy and paste this code to your MainActivity, but remember keep your package name unchanged, my package name is “com.thirteenov.lightweightnotetaker” so you must your own package name as it is your unique app identifier.
The next step is to add WebView to your layout file in Android Studio. Delete everything in your layout before adding WebView. Then after you drag and drop the WebView, you need to make it full screen. Make sure you set the constraint correctly and...
As usual, to create a new project of anything, in this case Android project, we just need to follow the dialog wizard. I named this project LightWeight NoteTaker, a light weight html5 note taking app. The package name of this app is “com.thirteenov.lightweightnotetaker” . So...
Hi, I’m going to start creating an HTML5 based Android web app. I’ve just Installed Android Studio and it’s getting ready now (it’s currently downloading some updates before I can use it). So basically, the idea behind creating Android WebApp is to have a WebView...
With this simple snippet, we can check is the device is connected to internet or not: private boolean isConnected(){ ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo(); return activeNetworkInfo != null && activeNetworkInfo.isConnected(); } So this “isConnected()” returns true if it’s connected, otherwise it...
I have a directory in sdcard called “mydir” and there are lot of .png image files with another files. Then I want to list only that .png files and populate a ListView from it. I do it like this: String path = “/sdcard/mydir”; File directory...
Follow this short tutorial to create a ListView in Android. First let’s create the list view element in our layout file: <ListView android:id=”@+id/lblistview” android:layout_width=”match_parent” android:layout_height=”match_parent” android:layout_marginBottom=”8dp” android:layout_marginEnd=”8dp” android:layout_marginStart=”8dp” android:layout_marginTop=”8dp” app:layout_constraintBottom_toBottomOf=”parent” app:layout_constraintEnd_toEndOf=”parent” app:layout_constraintStart_toStartOf=”parent” app:layout_constraintTop_toTopOf=”parent” /> Then in your Java file: lblist = (ListView)findViewById(R.id.lblistview); String[] items =...
Try this snippet to convert JSON text into object and/or array in Java: JSONObject object = new JSONObject(jsontext); JSONArray array = jsonObj.getJSONArray(“somearray”); for (int i = 0; i < somearray.length(); i++) { JSONObject item = somearray.getJSONObject(i); String somevalue = item.getString(“somekey”); } jsontext is your JSON...
Let’s say we have a directory in device’s storage called “mydir” and there are files inside it. By using this snippet we can list all names of that files and folders: String path = Environment.getExternalStorageDirectory().getAbsolutePath() + “/maktabamajaziya”; String downloadedbooks = “”; File directory = new...
If we are making an app for Android greater than SDK 23, we need to request some sensitive permissions (for example, to write file in external storage) in run time. Here is a snippet to do so: if (Build.VERSION.SDK_INT >= 23) { if (checkSelfPermission(android.Manifest.permission.WRITE_EXTERNAL_STORAGE) ==...
With this snippet, we are able to check if a folder existed in device’s storage or not. If not, then we create it. Here is the snippet: File directory = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + “/afolder”); if (! directory.exists()){ directory.mkdir(); }
This is Java source code for Android, providing you with two functions: to take a photo using camera and to pick an image from gallery.
In this example, user’s device is showing it’s current latitude and longitude every 5 seconds. Coordinates are displayed inside Android Toast.
To upload an image from Android device to online server using PHP, first we need to create a PHP script to handle “post” request and store the image to a folder. So write this simple script on your server:
Initially if we use a WebView in our Android app, if there is a link and we click it, an intent manager is being called and asking how do we want to open that link. But we can manage it to open that link inside...
When you develop Android Web App, you may want to show loading bar or anything when the web view is still loading a page, so your web app looks nice.
I’m developing an app that the user should choose an image from Android gallery and then automatically loaded into Android ImageView and WebView together.
Just googling around and find useful Java library, okhttp3, to send http request in from Android app.