GithubHelp home page GithubHelp logo

isabella232 / app-sample-android-phonegap Goto Github PK

View Code? Open in Web Editor NEW

This project forked from adobe-marketing-cloud-apps/app-sample-android-phonegap

0.0 0.0 0.0 39.49 MB

Sample on how AEM content can be integrated into an existing native Android app.

License: Other

JavaScript 25.87% CSS 10.13% Java 62.22% Shell 0.02% HTML 0.48% Batchfile 1.28%

app-sample-android-phonegap's Introduction

Native Android App with Embedded Webview and AEM 6.2

A native Android example running a Cordova (ie. PhoneGap) WebView home page connected to AEM6.

This example demonstrates how a Cordova WebView can be added to an existing Android application that uses fragments. Once the Cordova WebView has been added and configured it will then be possible to supply any web content to this view for displaying within your Android app. Furthermore, it is also possible to include Cordova plugins with your Android app that the web content can take advantage of in order to access device features.

In this example AEM App web content is added to the Android app assets folder and delivered to the Cordova WebView. The web content from AEM takes advantage of the Cordova plugins for accessing the device filesystem, unzipping packages and geolocation.

The Phonegap documentation does provide some details on how to embed a Cordova-enabled WebView component as an Android activity.

This example however, embeds the Cordova WebView as an Android fragment instead in order to support the Android View Pager.

Minimum requirements for development

  1. Maven (tested: Apache Maven 3.2.2)
  2. Gradle (tested: 2.1)
  3. Git (tested: git version 2.3.2)
  4. Android SDK (tested: API 23)
  5. Android Studio (tested: 2.1)
  6. Cordova (tested: 5.3.3)
  7. node.js version >=0.12.x
  8. AEM 6.2

##Getting Started

This example contains two projects that need to be built and deployed. First there is the Android app itself. The app consists of one activity that uses a FragmentPager for moving between views. The Home Page view fragment injects a CordovaWebView and the remaining views are native Android. Second, there is an AEM compatible package that contains all the required content and components for rendering the web content that will be displayed by the app. Installing this package will allow you to manage all your web content within AEM and have it delivered to your Android app via content sync.

Android

###Setup

Before being able to build this example Android app ensure your development environment is set up correctly.

  1. Android SDK (http://developer.android.com/sdk/index.html)
  2. ANDROID_HOME environment variable
  3. Android Studio 2.0+

####References

###Build

  • Use Android Studio

or

Experience Manager (AEM Mobile 6.2)

  • First a package that contains the content to be managed by AEM needs to be installed.

      cd content
      mvn -PautoInstallPackage clean install
    
  • Then download the content sync ZIP of the content from AEM Mobile.

      http://localhost:4502/content/mobileapps/geometrixx-webview/shell.cli-dev.zip
    
  • Unzip to your local file system

  • Go to the Android platform of the phonegap project you just built

      cd platforms/android
    
  • Copy the following files/directories to platforms/android

    • www (web content)
    • res/xml (cordova config)

Build Scripts

Several build scripts have been created to make it easier to synchronize the native android project with updated content from AEM.

  • Install required modules

      npm install
    
  • Download content package from AEM

      npm run fetch
    
  • Merge ZIP contents with your Android project

      npm run merge        
    
  • Download and merge at the same time

      npm run full
    

OTA Updates

In order to support OTA updates the content package needs to be replicated to a publish server.

Manually Updating Cordova

cordova create cordova
cd cordova
cordova platform add android

Add plugins

cordova plugin add cordova-plugin-file@^4.3.0
cordova plugin add cordova-plugin-file-transfer@^1.6.0
cordova plugin add cordova-plugin-dialogs@^1.2.1
cordova plugin add phonegap-plugin-contentsync@^1.2.4
cordova plugin add [email protected]

Copy everything to platform/android

src
assets/www/plugins
assets/www/cordova.js
libs
res/xml/config.xml
cordova
CordovaLib

##Tutorials

The following tutorials provide more details on how components of this example were created.

  1. Pre-Cordova 4.0 Embedding a Cordova WebView in an Android Fragment
  2. Coming Soon! [Embedding a Cordova WebView in an Android Fragment with Cordova 4.0+]

app-sample-android-phonegap's People

Contributors

arumsey avatar johobot avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.