Establish App Development Environment
You can develop a Nexacro Platform-based Android app by using Android Studio, the official app development tool of Android. Otherwise, you can use App Builder, which is one of Nexacro Platform products. This chapter explains how to develop an app by using Android Studio. The process of developing a Nexacro Platform-based Android app is basically the same as that of a usual Android app.
If you have established the app development environment already, you can skip this section, Establish App Development Environment.
The installation file of Android Studio includes a software development kit (SDK). Click on the below link to download the installation file appropriate for your running environment.
https://developer.android.com/studio/index.html
This chapter is written based on the 3.5.2 version of Android Studio.
Develop App Project
Once the app development environment is established, open Android Studio to get ready to develop an app running in Android. Before entering an app project, you should find the archive files that you built in Nexacro Studio and locate them in the designated directory.
Create a project
1
Unless you have already opened a project , create a new project in the Welcome to Android Studio window. Click Start a new Android Studio project as seen in the below picture.
If you want to create a new project with a project already opened, navigate to the below menu.
File > New > New Project
2
Choose a project template provided by Android.
Selection of templates affects an app structure, screen layout as well as the composition of files. Since it is enough for us to have a basic project that just can contain a Nexacro Platform-based app, select Empty Activity and click Next.
3
Configure some settings including the app name, package name and project location.
Description | ||
---|---|---|
1 | Name | Specify the name of your app. |
2 | Package Name | Specify the package name. |
3 | Save location | Specify the location where you want to locally store your project. |
4 | Language | Select the development language. Although the default language is Kotlin, Java is used in this chapter's sample. |
5 | Minimum API | Set the minimum level of an SDK. Whenever you change the SDK level, the information appears below about the device compatibility with the relevant API level. |
The minimum level of Android that Nexacro Platform supports is 5.0. Accordingly, you should choose an SDK that supports the API level 21 or higher.
4
As soon as you click the Finish button, the project is created.
As the project window is opened, additional necessary files are downloaded and installed automatically.
5
Set the Java Development Kit (JDK) embedded in Android Studio.
Go to the JDK location option in the menu [File > Project Structure] and select "Use embedded JDK".
Set Nexacro Platform libraries
Libraries provided by Nexacro Platform for developing an Android app include a Java Archive (JAR) file as well as 32-bit and 64-bit shared library (or shared object) files. Without any additional settings, you just need to copy those files to each designated directory to add the libraries to your Android project.
File | Path |
---|---|
Java Archive (nexacro17.android.jar) | [project path]\app\libs\ |
32-bit shared library (libnexacro17.so) | [project path]\app\src\main\jniLibs\armeabi-v7a\ |
64-bit shared library (libnexacro17.so) | [project path]\app\src\main\jniLibs\arm64-v8a\ |
If you want to copy the library files to each designated location in your actual project, you should select the Project view option from the dropdown at the top of the Project window. When you install Android Studio, the view mode is set to Android by default. You should change the view mode to Project to see the actual file structure of a project.
Copy the nexacro17.android.jar file to the directory [project path > app > libs]. For the libnexacro17.so file, navigate to the directory [project path > app > src > main] at first. Then, after creating the [jniLibs > armeabi-v7a] folder for the 32-bit library and [jniLibs > arm64-v8a] folder for the the 64-bit library under the main folder, copy libnexacro17.so to each of the created folders. The below picture shows the resulting folder structure.
You can copy and paste files directly from File Explorer into Android Studio. When you paste a file into each location, the Copy window appears as seen in the below picture to allow you to change the name of the file and the directory where the file is saved. In this sample, just click the OK button without any change.
You should navigate to the Java Archive file that you copied to the project's library directory and add it as a library to allow the project to refer to the file. Right-click on nexacro17.android.jar and select Add As Library from the context menu.
To check whether the library has been added successfully, right-click on your app and select Open Module Settings from the context menu.
Go to the menu Dependencies and check whether the library is added.
Starting August 1, 2019, your apps published on Google Play will need to support 64-bit architectures.
https://developer.android.com/distribute/best-practices/develop/64-bit
64-bit shared libraries do not work in mobile devices with 32-bit CPUs. When both a 32-bit and 64-bit shared library exist, the latter takes priority.
Set resources
In this stage, you can set launch images, icons, messages and layouts applied to your app. The Android system can offer optimal settings for screens if you make a list of resources according to device screen sizes and screen densities and then allocate each of them to appropriate folders.
The Android system can determine appropriate resources for certain device screens and screen densities. If there are no appropriate resources for a certain device screen, however, the system will use default resources by scaling them up or down.
The below picture shows the structure of the resource folder, which is automatically created at the creation of a project. Developers distribute image or XML files to each appropriate folder according to resource types.
The format of a resource directory name is <resource type>-<configuration qualifier>. Configuration qualifiers include size (small, normal, large..), density (ldpi, mdpi, hdpi, xhdpi..), orientation (land or port) and screen aspect (long or notlong). For example, the drawable-xxhdpi directory contains images of extra high density and an XML resource file. A directory without a configuration qualifier—for example, drawable—is a folder that contains default resources. Therefore, the drawable directory contains default resources that are used by the system to draw a screen.
See the official Android user guide for further details on resources.
Set images
Images used in an app should be placed in each appropriate directory under the res directory according to screen densities. For example, images for a splash screen should be located in drawable folders while app icon images are placed in mipmap folders. Image files should be put in different folders according to the resolution levels that are supported by the relevant app.
Images | Description |
---|---|
ic_launcher.png | This is the image of an app icon that appears on the home screen. You can change the name of the image file in the AndroidManifest.xml file. |
splashimage_phone_landscape.png | This is the image of a splash screen in landscape orientation, applied to an Android phone. (The name must be written in lower case.) |
splashimage_phone_portrait.png | This is the image of a splash screen in portrait orientation, applied to an Android phone. (The name must be written in lower case.) |
splashimage_pad_landscape.png | This is the image of a splash screen in landscape orientation, applied to an Android tablet. (The name must be written in lower case.) |
splashimage_pad_portrait.png | This is the image of a splash screen in portrait orientation, applied to an Android tablet. (The name must be written in lower case.) |
Even if you do not set images separately for the launcher icon and splash screen, your app will operate nevertheless because the default settings will be applied instead.
Set icon images
You can modify icon files after creating a project. Right-click on your app and select [New > Image Asset] from the context menu to open Image Asset Studio. You can configure icon files through the editor.
Set images of a splash screen
You can simply configure the splash screen displayed while your app is launching. In the above table, the files whose names begin with splashimage_ are splash screen images used in a Nexacro Platform-based app. To set such images, you should copy images to the /res/drawable directory and then change the file names as seen in the below picture.
Set strings
Set the strings used in your app. To this end, modify the strings.xml file as below. strings.xml is a default file created under the directory /res/values when the project is created.
The below example shows the default strings used in Nexacro Platform-based apps. While you can change those strings to suit your situation, you should not change their name attributes because they are referenced from the app. If you do not set these default strings, your app may not work properly.
$r_title(strings.xml) <?xml version="1.0" encoding="utf-8"?> <resources> <!-- The string whose name attribute is "app_name" defines the app name actually used in devices. By changing this string, therefore, you can change the app name displayed on device screens. --> <string name="app_name">HelloAndroid</string> <string name="action_settings">Settings</string> <!-- Clipboard --> <string name="copy">Copy</string> <string name="paste">Paste</string> <string name="cut">Cut</string> <string name="close">Close</string> <string name="selectall">Select All</string> <string name="selectword">Select Word</string> <string name="needupdate">It needs an update. \nAfter completion, Please restart.</string> <string name="loadingFail">First loading fails. \nPlease restart.</string> <string name="updateFail">Update fails. \nPlease restart.</string> <string name="notexist">Start file does NOT exist. \nPlease restart.</string> <string name="BeingUpdated">Being updated.</string> <string name="wantreplace">There is a file of the same name. Do you want to replace? </string> <string name="ok">OK</string> <string name="cancel">Cancel</string> <string name="move">Move</string> <string name="upper">Upper</string> <string name="filter">Filter</string> <string name="home">Home</string> <string name="nofilename">No File Name.</string> <string name="checkforupdates">Check for update.</string> <string name="installforupdates">Install update.</string> <string name="downloadingforupdates">Downloading update.</string> <string name="force_close">Update is Completed.</string> <string name="LoadingPleaseWait">Loading… \nPlease Wait…</string> <!-- Accessibility widget role --> <string name="alert">alert</string> <string name="pushbutton">pushbutton</string> <string name="combobox">combobox</string> <string name="checkbutton">checkbutton</string> <string name="radiobutton">radiobutton</string> <string name="text">text</string> <string name="list">list</string> <string name="listitem">listitem</string> <string name="statictext"></string> <string name="graphic">image</string> <string name="spacebar">space bar</string> <string name="textdeleted">deleted</string> <!-- Accessibility widget statue --> <string name="checked">checked</string> <string name="unchecked">unchecked</string> <!-- Accessibility reaction --> <string name="click">click</string> <!-- Splash message --> <string name="start_initialize">Start Initialization</string> <string name="check_license">Check License</string> <string name="load_frameworkmodule">Load Framework Module</string> <string name="load_extendmodule">Load Extended Module</string> <string name="execute_frameworkscript">Execute Framework Script</string> <string name="load_application">Load Application</string> <string name="load_failapplication">Fail to Initialize Application. Click And Close</string> </resources>
While you can change those strings to suit your situation, you should not change their name attributes because they are predefined for the app.
If you want to add strings written in a non-English language like Korean or Japanese, add a folder under the res directory with a name like values-ko or values-ja. Then, add the strings.xml file to the created folder. See the official Android user guide for further details.
Set a layout
Define the layout of your app as displayed on devices. Define the layout structure as shown in the below sample code because the layout is just used to let an Android app hold a Nexacro Platform-based app as a child view. If you do not set a layout, the Nexacro Platform-based app you developed will not be printed on the screen properly when the resulting Android app is launched.
Create a layout XML file under the directory /res/layout with the name nexacro_app.xml and modify the file as below. To add a new layout file, select the menu [File > New > XML > Layout XML File].
$r_title(nexacro_app.xml) <?xml version="1.0" encoding="utf-8"?> <!-- nexacro_app.xml --> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/nexacro_activity" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/transparent" tools:context="com.nexacro.deviceAPI.FileDialogActivity" > <com.nexacro.view.NexacroLayout android:id="@+id/nexacro_layout" android:background="@android:color/transparent" android:layout_width="match_parent" android:layout_height="match_parent" > </com.nexacro.view.NexacroLayout> </FrameLayout>
If you do not set a layout, your app may not be printed on the screen properly or an error may occur.
Set Config
Set the nexacro_config.xml file to apply the functionalities provided by Nexacro Platform to your app. You can activate features including app updating, notification and error processing. You should create the nexacro_config.xml file by yourself and locate the file under the directory [Project > app > src > main > res > xml]. This file should be included in the project when your app is built in Android Studio.
Even if the nexacro_config.xml file does not exist, there will be no problem in running your app because the default configuration will be applied instead.
The nexacro_config.xml file is in the XML format and written like the below sample.
<?xml version="1.0" encoding="UTF-8"?> <nexacro-config> <application dialog-position="center" file-logging="true" quiet="false"/> <updator cancelable="true" force="true" errormsg="true" quiet="false"/> <xpush-server requestMissingMessage="true"/> <notification enable="true" handler="com.nexacro.notification.DefaultHandler"/> </nexacro-config>
The below table shows the features that you can set in nexacro_config.xml.
As Nexacro Platform has adopted Firebase Cloud Messaging (FCM) since the version 17.0.0.1800, the project-number and ui-handler properties are no longer available. Therefore, the description about those properties has been deleted.
Features | Property | Value | Description |
---|---|---|---|
application | dialog-position | "top" | "center" | "bottom" | This property sets the position of a pop-up for showing the progress of app updating. |
file-logging | "true" | "false" | This property determines whether to log loading errors in the form of a file. If "true", your app will attempt to save a log file first to the external storage (context.getExternalCacheDir()). If the external storage is unavailable, the internal storage is the next destination (context.getCacheDir()). The directory and file name for saving a log file is as follows: [external/internal storage]/logs/yyyy_MM_dd.txt. | |
quiet | "true" | "false" | This property determines whether to display a pop-up that indicates app launching. If "true", the message "Loading Application" will not be printed. | |
updator | force | "true" | "false" | This property determines whether to display a pop-up for announcing the existence of an update, contained in start_android.json. |
cancelable | "true" | "false" | If "true", updating will be conducted automatically without pop-up announcement. | |
errormsg | "true" | "false" | This property determines whether to display a pop-up for showing the error information when the loading of the app fails. | |
quiet | "true" | "false" | This property determines whether to display a pop-up that asks you whether to update the app. Even if you specify "true", the progress of app updating will be displayed when there is an update file. | |
xpush-server | requestMissingMessage | "true" | "false" | This property determines whether to automatically request messages that you have not received from an XPush server. |
notification | enable | "true" | "false" | This property determines whether to use the notification feature. |
handler | “[function name]” | This property sets a function to process the message or data of a notification. The default value is “com.nexacro.notification.DefaultHandler”. |
Click on the below links for the details on the storage path defined by the file-logging property.
https://developer.android.com/reference/android/content/Context.html#getExternalCacheDir()
https://developer.android.com/reference/android/content/Context.html#getCacheDir()
Set build environment
You should modify MainActivity.java and AndroidManifest.xml —default files created in the process of creating an Android project—in a way that suits Nexacro Platform.
MainActivity.java
If you do not specify another name for a main activity at the creation of a project, the activity will be created with the name MainActivity.java. To find the file MainActivity.java, navigate to the folder of the relevant package name under the directory [project > app > src > main > java]. Then, modify the file as below.
$r_title(MainActivity.java) package com.example.helloandroid; import com.nexacro.NexacroResourceManager; import com.nexacro.NexacroUpdatorActivity; import android.content.Intent; import android.os.Bundle; import android.view.View; public class MainActivity extends NexacroUpdatorActivity { public MainActivity() { super(); setBootstrapURL("http://[URL]/start_android.json"); setProjectURL("http://[URL]/"); } @Override protected void onCreate(Bundle savedInstanceState) { NexacroResourceManager.createInstance(this); NexacroResourceManager.getInstance().setDirect(false); Intent intent = getIntent(); if(intent != null) { String bootstrapURL = intent.getStringExtra("bootstrapURL"); String projectUrl = intent.getStringExtra("projectUrl"); if(bootstrapURL != null) { setBootstrapURL(bootstrapURL); setProjectURL(projectUrl); } } super.onCreate(savedInstanceState); } @Override public void setContentView(View view) { super.setContentView(view); } }
In the above sample, the text written in bold should be replaced with something appropriate for your settings.
The 15th and 16th lines are written to designate two addresses: one is for a bootstrap and the other is for the project's source code. As an argument of the setBootstrapURL method, you should specify the server URL for the start_android.json file, which is created in Nexacro Studio. As an argument of the setProjectURL method, you should specify the server URL for the directory where the source code of the relevant project is generated. You should add a slash (/) at the end of the path to the generated source code.
15 setBootstrapURL("http://192.168.0.1:8080/nexacro/_android_/start_android.json"); 16 setProjectURL("http://192.168.0.1:8080/nexacro/_android_/");
The 22nd and 23rd lines should be adjusted according to the update type, which is set in the Packing (Archive&Update) stage of Nexacro Studio. If the update type is set to "Server", you should specify "true" as an argument of the setDirect method written in the 23rd line. If the update type is set to "Update (Local+Server)" or "Local", you should specify "false".
22 NexacroResourceManager.createInstance(this); 23 NexacroResourceManager.getInstance().setDirect(true);
If you make a mistake when setting the bootstrap URL, project URL or resource manager, your app may not function properly.
In the 17.0.0.2100 version or later, you can change the value of the screenid property by using the setScreenid method with the onCreate callback.
public void onCreate(Bundle savedInstanceState) { NexacroResourceManager.createInstance(this); NexacroResourceManager.getInstance().setScreenid("Tablet_screen"); }
AndroidManifest.xml
The AndroidManifest.xml file, which is located in the directory [project > app > src > main], contains basic information about your app and necessary information for performing specific functionalities. Modify the file as shown in the below sample. Moreover, the information about the package and main activity—the two pieces of text in bold in the below sample—should be changed according to the settings of your project.
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.helloandroid"> <uses-feature android:glEsVersion="0x00020000" android:required="true" /> <!-- network access Permission --> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" /> <!-- storage access permission --> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_INTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" /> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> <activity android:name="com.example.helloandroid.MainActivity" android:label="@string/app_name" android:theme="@android:style/Theme.NoTitleBar"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name="com.nexacro.NexacroActivity" android:alwaysRetainTaskState="true" android:configChanges="orientation|keyboardHidden|screenSize" android:launchMode="singleTop" android:theme="@android:style/Theme.NoTitleBar" android:windowSoftInputMode="adjustResize" > </activity> <!-- FileDialog --> <activity android:name="com.nexacro.deviceAPI.FileDialogActivity" android:screenOrientation="sensor"> <intent-filter> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <meta-data android:name="com.google.android.gms.version" android:value="google_play_services_version" /> </application> </manifest>
If your app targets the SDK version 28 or higher, you must set the usesCleartextTraffic attribute to "true" to maintain HTTP traffic.
If you do not set the attribute, HTTP traffic will not be allowed because the attribute defaults to "false".
https://developer.android.com/guide/topics/manifest/application-element#usesCleartextTraffic
<application
android:allowBackup="true"
android:usesCleartextTraffic="true"
Set necessary permissions and other information according to the features that your app is equipped with. For example, add the below sample to the manifest file if you want your app to provide the camera feature.
... <uses-permission android:name="android.permission.CAMERA" /> <activity android:name="com.nexacro.deviceAPI.CameraListener" android:screenOrientation="landscape"> <intent-filter> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <uses-feature android:name="android.hardware.camera" android:required="false"/> <uses-feature android:name="android.hardware.camera.autofocus" android:required="false"/> ...
The below list contains sets of code to set the permissions for frequently-used features. Pick items necessary for your app and add them to AndroidManifest.xml. If you want to see all the permissions defined in Android, go to Manifest.permission.
If you execute your app without setting the permissions necessary for certain features of your app, relevant features will not function with a message that you do not have a permission for the feature.
<!-- AudioPlayer, AudioRecorder --> <uses-permission android:name="android.permission.RECORD_AUDIO" /> <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<!-- Call --> <uses-permission android:name="android.permission.CALL_PHONE" />
<!-- Contact --> <uses-permission android:name="android.permission.READ_CONTACTS" /> <uses-permission android:name="android.permission.WRITE_CONTACTS" />
<!-- Camera --> <uses-permission android:name="android.permission.CAMERA" /> <activity android:name="com.nexacro.deviceAPI.CameraListener" android:screenOrientation="landscape"> <intent-filter> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <uses-feature android:name="android.hardware.camera" android:required="false"/> <uses-feature android:name="android.hardware.camera.autofocus" android:required="false"/>
<!-- Geolocation --> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<!-- Map --> <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/> <uses-library android:name="com.google.android.maps" /> <meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="user value" />
If you want to use Google Maps, you need to get an API key and insert it to the relevant configuration file. Click on the below link to see the details about it.
https://developers.google.com/maps/documentation/android/start#obtain_a_google_maps_api_key
Nexacro Platform has adopted Firebase Cloud Messaging (FCM) since the version 17.0.0.1800.
The previous notification feature based on Google Cloud Messaging (GCM) has been deactivated since April 11 2019. Therefore, your app's notification feature should migrate to Firbase Cloud Messaging (FCM) while you need to update Nexacro Platform with the version 17.0.0.1800 or higher
https://developers.google.com/cloud-messaging/
About FCM messages
https://firebase.google.com/docs/cloud-messaging/concept-options
<!-- Adding NexacroNotificationService --> <service android:name="com.nexacro.notification.NexacroNotificationService"> <intent-filter> <action android:name="com.google.firebase.MESSAGING_EVENT" /> </intent-filter> </service> <!-- Adding NexacroActivity intent-filter --> <activity android:name="com.nexacro.NexacroActivity" android:launchMode="singleTask" android:noHistory="false" android:hardwareAccelerated="true" android:windowSoftInputMode="adjustResize" android:configChanges="orientation|keyboard|keyboardHidden|screenSize|navigation|uiMode"> <intent-filter> <action android:name="OPEN_NEXACRO_ACTIVITY_EXAMPLE" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity>
If you use FCM, the below code listings should be added to the build.gradle file. Basically, this configuration is automatically performed in Android Studio. If not performed automatically, however, you need to add the below code listings by yourself and download the google-services.json file, which is created in the Firebase console. Then, copy the JSON file to the module directory of your app.
Add Firebase to your Android project
https://firebase.google.com/docs/android/setup
buildscript { // Adding repositories repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.2.1' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files // Adding google service classpath 'com.google.gms:google-services:4.0.1' } } allprojects { // Adding repositories repositories { google() jcenter() } } task clean(type: Delete) { delete rootProject.buildDir } dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') implementation 'com.android.support:appcompat-v7:27.1.1' implementation 'com.android.support:support-v4:27.1.1' implementation 'com.google.android.gms:play-services-maps:16.0.0' implementation 'com.google.android.gms:play-services-location:16.0.0' implementation 'com.google.firebase:firebase-core:16.0.6' implementation 'com.google.firebase:firebase-messaging:17.3.4' compile 'com.android.support:multidex:1.0.3' implementation 'com.android.support:design:27.1.1' implementation files('libs/nexacro17.android.jar') } apply plugin: 'com.google.gms.google-services'
You should change the versions of play-services
if your app targets the SDK version 28 or higher.
implementation 'com.google.android.gms:play-services-maps:16.1.0'
implementation 'com.google.android.gms:play-services-location:16.1.0'
<!-- SMS --> <uses-permission android:name="android.permission.SEND_SMS" /> <uses-permission android:name="android.permission.RECEIVE_SMS" /> <uses-permission android:name="android.permission.READ_SMS" /> <uses-permission android:name="android.permission.WRITE_SMS" /> <receiver android:name="com.nexacro.deviceAPI.SmsRecv"> <intent-filter> <action android:name="android.provider.Telephony.SMS_RECEIVED" /> </intent-filter> <intent-filter> <action android:name="android.provider.Telephony.WAP_PUSH_RECEIVED" /> <data android:mimeType="application/vnd.wap.mms-message" /> </intent-filter> </receiver>
<!-- Vibrator --> <uses-permission android:name="android.permission.VIBRATE" />
<!-- FileDialog --> <activity android:name="com.nexacro.deviceAPI.FileDialogActivity" android:screenOrientation="sensor"> <intent-filter> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity>
<!-- Bluetooth --> <uses-permission android:name="android.permission.BLUETOOTH" /> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <service android:name="com.nexacro.deviceAPI.BluetoothLEAdapterService" android:enabled="true" android:exported="true"> </service>
<!-- ExternalAPI --> <uses-permission android:name="android.permission.GET_TASKS" />
<!-- Etc --> <uses-permission android:name="android.permission.GET_ACCOUNTS" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" />
Set your app stand-alone in disconnected environments
You can run your app without a network connection if you set the update type to "Local" or "Update (Local+Server)" when packing the app in Nexacro Studio. Normally, the Local type is appropriate for users who do not need a network connection while the Update (Local+Server) type suits users who usually maintain communications with servers but still need to operate apps even when networking is in trouble. To make your app stand-alone, you should prepare files necessary for execution and load them onto the app in the building process.
The files necessary for executing an app include modules, sources, resources and start_android.json, which are all obtained through the Packing (Archive&Update) process of Nexacro Studio. If you load those files onto the "archive" folder under the "assets" directory in your Android project before building an app, you can run the app without a network connection.
Even if you set the update type to "Local" in the Packing (Archive&Update) process of Nexacro Studio, you must specify a bootstrap URL in the MainActivity.java of your Android project.
For example, you can specify a random URL like the below ones, which is either virtual or unused actually.setBootstrapURL("http://192.168.0.1/_android_/start_android.json");
setProjectURL("http://192.168.0.1/_android_/");
1
Create the "assets" folder in your project in Android Studio.
The "assets" directory is a logical storage used in an Android app. After creating the assets folder in your Android project, prepare files to use in the app, copy those files to the assets folder and build the APK of your app. By doing so, you can use those files when you launch the app. Since the assets folder is read-only, the files in this directory should not change during the execution of the app.
Right-click on app, the root folder of your project, and select [New > Folder > Assets Folder] from the context menu. Create the assets folder under the directory [project > app > src > main].
2
Create the "archive" folder under the assets directory.
Right-click the assets folder under the directory [project > app > src > main] and select [New > Directory] from the context menu to create the "archive" folder under the assets folder.
3
Copy module, source and resource files to the assets/archive directory.
Copy module, source and resource files to the [project > app > src > main > assets > archive] directory. You can copy and paste files directly from File Explorer into Android Studio.
4
Check whether the folders and files have been added to the project successfully.
Go to the project view in Android Studio and check whether the added assets/archive folder and files under the folder are there.
Build
App test
You can test your app by connecting an Android device to your PC using a USB cable. In that case, you need to toggle the USB debugging option in the Developer Options menu in the device and to install a driver for the device.
Click on the below link to learn how to select the USB debugging option.
Select the Run menu of Android Studio, which allows you to build an APK, install it on your device and then execute the app. Upon selecting the menu, you can choose a device for running your app.
Run > Run 'App'
As for Nexus One and Optimus One, users cannot spare any space in the internal storage of each device. Therefore, your app cannot be installed successfully in both devices unless you add an external memory card.
Tests cannot be conducted with Android virtual devices.
You can see the log messages for executing the app through the Logcat window, which is situated at the bottom of the Android Studio screen.
Create installation file
To distribute your app that has been built completely, you should create a keystore that can identify your app and then should create a signed APK file. You need to create a keystore file just once at the beginning. When the app is updated, you can use the keystore file that you created already.
Click on the below link to go to the official Android user guide where you can learn how to create a keystore and signed APK.
Select the menu [Build > Generate Singed Bundle/APK].