đŸ Archived View for gemini.ctrl-c.club âș ~ssb22 âș html2apk.gmi captured on 2024-08-31 at 12:43:59. Gemini links have been rewritten to link to archived content
âŹ ïž Previous capture (2024-03-21)
-=-=-=-=-=-=-
This is a method for making a standalone Android âappâ from a collection of static HTML and Javascript files, such as files from Offline HTML Indexer or Charlearn mobile.âApps made using the files below should run on any version of Android (v1+), and extra Javascript functions are provided to place text on the Android clipboard.
Packaging an offline site as an app makes it easier for beginners to install, but it does mean the app will not automatically copy any âaccessibilityâ options that were set in the main browser.âThis app will make some attempt to compensate (and it includes setZoomLevel code from Annotator Generator if you need to make a custom zoom control), but for maximum accessibility you should always ship an alternative version of your HTML that is *not* packaged as an app.
If your app uses âlocal storageâ, this requires Android 2.1+ (you can use localStorage.setItem etc in scripts; âcookiesâ tend not to work).
UTF-8 encoding is assumed.
In June 2015 Google deprecated the Android Developer Tools (ADT), and in June 2017 removed the download, saying âyou should immediately switchâ to the newer Android Studio.âSince Android Studio does not work on all equipment, you might find these instructions for the older ADT useful if you happen to have downloaded it before June 2017 (although I do suggest checking if your older equipment can at least host a virtual machine with a suitable GNU/Linux installation to run Android Studio).âApp updates compiled in old ADT have been rejected by Googleâs âPlay Storeâ since 2018 and may not be âside-loadableâ after Android 10, plus youâll have to remove dark-mode code from styles.xml if compiling on old ADT.
1. In ADT, go to File / New / Android application project
2. Enter the following information:
Application Name - Any short name you wish (will be shown in the phoneâs app menu)
Project Name - anything you want (just needs to be unique on your development computer)
Package Name - org.ucam.ssb22.html
Minimum Required SDK - API 1: Android 1.0
or API 7 if you use local storage
3. Leave everything else as default, but make a note of the project directory (probably mentioned on the second setup screen as âlocationâ)
4. Switch out of ADT, and unpack this html2apk.zip into the project directory, saying âyesâ to overwrite (it should overwrite 2 files)
5. If you use local storage, edit src/org/ucam/ssb22/html/MainActivity.java and uncomment the lines as instructed
6. (Optional) If you donât want your app to be reloaded with every screen or keyboard change, edit the top-level AndroidManifest.xml file and after <activity put android:configChanges="orientation|screenSize|keyboardHidden" (you will likely need to re-start the ADT after saving this edit)
7. If you are distributing your app to others, or if you intend to load more than one HTML-based app onto your device, please change the package name (in AndroidManifest.xml and MainActivity.java, and by renaming the directories under src) to a (sub)domain you own.âThis is needed because, if another application already on the device has the same package name, then installing yours will overwrite the one thatâs already there and vice versa.â(But if you change the package name when the app is already deployed, attempts to install the new version will leave the previous version on the device *as well*.)
8. Place your HTML (and any related files) into the assets subdirectory, with index.html as the starting page
9. Back in ADT, go to Run / Run As / Android application.âIt should let you launch a virtual Android device.âItâs probably best not to interact with the virtual Android device until the ADT has finished setting it up (check for messages in ADTâs Console window).âIf the install fails, try Run again.
10.âIf the install is successful, then you should see your application running when you unlock the Android device in the emulator.
11.âThe .apk file will have by this time been placed in the bin subdirectory of the project directory.âThis file can be copied to a Web server and linked to.â(A connection will be required for installing from the Web, but not for usage later.)âIt might be necessary to go to âApplication settingsâ or âSecurityâ and enable âUnknown sourcesâ before the app will install on a real phone.
Command-line builds are easier to automate, and also work if youâve upgraded to the newer Android Studioâyou just need to make sure the directories are set correctly for SDK etc.âThere is an example script in html2apk.zip called compile.shâdonât forget to change the variables at the beginning, and to change the package name in other files as described above.
All material © Silas S. Brown unless otherwise stated. Android is a trademark of Google LLC. Google is a trademark of Google LLC. Javascript is a trademark of Oracle Corporation in the US. Linux is the registered trademark of Linus Torvalds in the U.S. and other countries. Any other trademarks I mentioned without realising are trademarks of their respective holders.