A plugin system that runs like a browser, but instead of load web pages, it load apk plugins which runs natively on Android system.

Overview

Android Dynamic Loader

Android Dynamic Loader is a plugin system. The host application is like a browser, but instead of load web pages, it load plugins which runs natively on Android system.

You can download the demo from https://github.com/mmin18/AndroidDynamicLoader/raw/master/host.apk (35k).

HelloWorldDemo

BitmapFunDemo

How to run the sample plugins

The sample plugins is under workspace folder, but do not try to run them directly, it won't start.

First you need to install host.apk on your phone (or you can build the Host project yourself)

Also you need to make sure the Android SDK and Ant is installed and android-sdk/tools, android-sdk/platform-tools, ant is in your PATH.

Run the following commands:

chmod +x tools/update.sh
tools/update.sh workspace
cd workspace
ant run

If it shows "device not found", make sure your phone is connected or simulator is running. "adb devices" will tell.

Since we don't specific a default entry in workspace.properties, it will popup a window and let you choose one. I suggest bitmapfun.

About UI Container

In a normal Android application, we use Activity as the root UI container. But since Activity is registered in AndroidManifest.xml, and we can't modify manifest in runtime, we must find an alternative UI container - Fragment.

The Fragment itself, introduced in Android 3.0 Honeycomb, is a perfect UI container, and it has lifecycle and state management.

Once the plugin and its dependency is downloaded, an Activity (MainActivity.java) will be started, create an instance of the specific fragment, and add the fragment into the root view.

See the HelloFragment.java sample.

About URL Mapping

Since we use Fragment as UI container, each page is implemented in Fragment instead of Activity. So how do we start a new page?

We use URL, just like a browser does. For instance, in a browser, we open http://mydomain.com/helloworld.html. In plugins, we open app://helloworld.

Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("app://helloworld"));
startActivity(i);

Each host is mapped to a single fragment, you define the url mapping table in project/fragment.properties.

See the helloworld fragment.properties sample.

About Resources

In the plugins, we pack resources and codes in the same package. We use R.java as the index of resources.

But instead of using context.getResources(), we use MyResources.getResource(Me.class) to get the resources which in the same package as Me.class.

Here is a sample in HelloFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
		Bundle savedInstanceState) {

	// MyResources manages the resources in specific package.
	// Using a Class object to obtain an instance of MyResources.

	// In this case, hello.xml is in the same package as HelloFragment class

	MyResources res = MyResources.getResource(HelloFragment.class);

	// Using MyResources.inflate() if you want to inflate some layout in
	// this package.
	return res.inflate(getActivity(), R.layout.hello, container, false);

}

You can use MyResources to get drawable, string, or inflate layout.

Folders

/Host contains the host application (build as host.apk).

/tools/update.sh checks your environment and helps you config your plugins. You should always run it once after git clone or create a new plugin.

/workspace/sample.helloworld is a most simple plugin. /workspace/sample.helloworld/fragment.properties defines the url mapping of your fragments.

/site/***/site.txt is the definition file for all the plugins files, dependency and fragments url mapping table.

You might also like...
Android common lib, include ImageCache, HttpCache, DropDownListView, DownloadManager, Utils and so on
Android common lib, include ImageCache, HttpCache, DropDownListView, DownloadManager, Utils and so on

android-common-lib 关于我,欢迎关注 微博:Trinea 主页:trinea.cn 邮箱:trinea.cn#gmail.com 微信:codek2 主要包括:缓存(图片缓存、预取缓存、网络缓存)、公共View(下拉及底部加载更多ListView、底部加载更多ScrollView、

A Model-View-Presenter / Model-View-Intent library for modern Android apps

Mosby A Model-View-Presenter and Model-View-Intent library for Android apps. Dependency dependencies { compile 'com.hannesdorfmann.mosby3:mvi:3.1.1

dexposed enable 'god' mode for single android application.

What is it? Dexposed is a powerful yet non-invasive runtime AOP (Aspect-oriented Programming) framework for Android app development, based on the work

A small, yet full-featured framework that allows building View-based Android applications
A small, yet full-featured framework that allows building View-based Android applications

Conductor A small, yet full-featured framework that allows building View-based Android applications. Conductor provides a light-weight wrapper around

A Job Queue specifically written for Android to easily schedule jobs (tasks) that run in the background, improving UX and application stability.

This Project is Deprecated! Thanks to everybody who've used Android Priority JobQueue. It was designed in a world where there was no JobScheduler, RxJ

LiteOrm is a fast, small, powerful ORM framework for Android. LiteOrm makes you do CRUD operarions on SQLite database with a sigle line of code efficiently.

#LiteOrm:Android高性能数据库框架 A fast, small, powerful ORM framework for Android. LiteOrm makes you do CRUD operarions on SQLite database with a sigle line

Kick-starts Android application development.

Synopsis If you've made it here, chances are you are not quite as satisfied with the Android application framework as you could be. Same for us, that'

Rosie is an Android framework to create applications following the principles of Clean Architecture.
Rosie is an Android framework to create applications following the principles of Clean Architecture.

Rosie The only way to make the deadline—the only way to go fast—is to keep the code as clean as possible at all times. — Robert C. Martin in Clean Cod

Create kotlin android project with one line of command.

README This is an android application template project built with kotlin language and some useful libraries. It provides a creator script to quickly c

Comments
  • Reorganize README

    Reorganize README

    make it more logical

    I spent about half an hour trying to understand implementation. The section were not logical.

    In this PR I also added "This implementation is using Andoid .apk file as plugin container."

    opened by paulvi 0
Owner
Tu Yimin
Tu Yimin
Cross-platform framework for building truly native mobile apps with Java or Kotlin. Write Once Run Anywhere support for iOS, Android, Desktop & Web.

Codename One - Cross Platform Native Apps with Java or Kotlin Codename One is a mobile first cross platform environment for Java and Kotlin developers

Codename One 1.4k Dec 23, 2022
A modern framework for full stack web apps in Kotlin

Kobweb is an opinionated Kotlin framework for creating websites and web apps, built on top of Web Compose and inspired by Next.js and Chakra UI.

Varabyte 425 Jan 8, 2023
Android part of the Android Studio(IntellijIDEA) OkHttp Profiler plugin

OkHttpProfiler Android Library Created by LocaleBro.com - Android Localization Platform The OkHttp Profiler plugin can show requests from the OkHttp l

Ievgenii 261 Dec 8, 2022
🚀Plugin for Android Studio And IntelliJ Idea to generate Kotlin data class code from JSON text ( Json to Kotlin )

JsonToKotlinClass Hi, Welcome! This is a plugin to generate Kotlin data class from JSON string, in another word, a plugin that converts JSON string to

Seal 2.8k Jan 3, 2023
Android Plugin Framework

Android Plugin Framework This project is pre-mature and may be changed very frequently. Introduction Android Plugin Framework (APF) aims to providing

Umeng Limited 322 Nov 17, 2022
Gradle plugin to deploy Android Snapshot Versions

Android Snapshot Publisher is a Gradle plugin to prepare and distribute Android Snapshot versions to multiple distribution sources in a simple and com

xmartlabs 144 Nov 29, 2022
Intellij Idea, Android Studio plugin for generating Kotlin data classes from JSON. Helps to avoid writing boilerplate code for model classes. Supports annotations for Gson, Moshi, Jackson.

JSONToKotlinClass Intellij Idea, Android Studio plugin. Plugin generates Kotlin data classes from JSON text. It can find inner classes in nested JSON.

Vasily 139 Dec 21, 2022
Small Warp Plugin developed in Kotlin

Warps A small warps plugin for the 1.17 SMP. Minecraft 1.17 Spigot Contributing Install Java 16 Fork this repo Clone your fork Make your changes Use h

MenuDocs 6 Feb 19, 2022
Nucleus is an Android library, which utilizes the Model-View-Presenter pattern to properly connect background tasks with visual parts of an application.

Nucleus Deprecation notice Nucleus is not under develpment anymore. It turns out that Redux architecture scales way better than MVP/MVI/MVVM/MVxxx and

Konstantin Mikheev 2k Nov 18, 2022
VasSonic is a lightweight and high-performance Hybrid framework developed by tencent VAS team, which is intended to speed up the first screen of websites working on Android and iOS platform.

VasSonic: A Lightweight And High-performance Hybrid Framework VasSonic is a lightweight and high-performance Hybrid framework developed by tencent VAS

Tencent 11.6k Dec 30, 2022