Skip to content

Inicialização do SDK

1. Inicialização

Somente após a inicialização bem -sucedida você pode usar a API fornecida por O SDK, caso contrário, a chamada da API falhará.

API

kotlin
/**
* Initialize the applet SDK
*
* @param application [android.app.Application] instance
* @param finAppConfig [FinAppConfig] instance, configuration
information for the applet framework
* @param finCallback Initialization status callback interface
*/
fun init(application: Application, finAppConfig: FinAppConfig,
finCallback: FinCallback<Any?>?)

Exemplo de uma chamada para ####

Nota

  1. Começando de de 2.13.102 Versão, o Philip applet sdk supports A configuração de várias informações do servidor para abrir applets Vários servidores diferentes ao mesmo tempo, por isso fornecemos uma maneira de Configure várias informações do servidor.
  2. O método de inicializar um único servidor com Builder().setAppKey e Builder().setAppSecret Pode ser desativado em O futuro, então por favor use o multi-Método de inicialização do servidor em Preferência.

:::: tabs ::: tab "Kotlin"

kotlin
val config = FinAppConfig.
 .setAppKey("SDK Key")
 .setAppSecret("SDK Secret")
Subscribe to DeepL Pro to edit this document.
Visit www.DeepL.com/profor more information.
 .setApiUrl("server address")
 .setApiPrefix("server interface request routing prefix")
 .build()
FinAppClient.init(application, config, object : FinCallback<Any?> {
 override fun onSuccess(result: Any?) {
 }
 override fun onProgress(status: Int, info: String?) {
 }
 override fun onError(code: Int, error: String?) {
 }
})

:::

::: tab "Java"

java
FinAppConfig config = new FinAppConfig. Builder()
 .setAppKey("SDK Key")
 .setAppSecret("SDK Secret")
 .setApiUrl("server address")
 .setApiPrefix("server interface request route prefix")
 .build();
FinAppClient. INSTANCE. init(this, config, new FinCallback< Object>() {
 @Override
 public void onSuccess(Object result) {
 }
 @Override
 public void onError(int code, String error) {
 Toast. makeText(SampleApplication. this, "SDK initialization
failed", Toast. LENGTH_SHORT). show();
 }
 @Override
 public void onProgress(int status, String info) {
 }
});
// Collection of server information
List< FinStoreConfig> storeConfigs = new ArrayList<>();
// Information on Server 1
FinStoreConfig storeConfig1 = new FinStoreConfig(
 "SDK Key Information", // SDK Key
 "SDK Secret information", // SDK Secret
 "Address of server 1", // Server address
 "Server 1's data upload server address", // the address of the data upload server
 "/api/v1/mop/", // Server interface request routing prefix
 "", // SDK fingerprint
 "encryption method" // encryption method, national:SM, md5: MD5
);
storeConfigs. add(storeConfig1);
// Information on Server 2
FinStoreConfig storeConfig2 = new FinStoreConfig(
 "SDK Key Information", // SDK Key
 "SDK Secret information", // SDK Secret
 "Address of server 2", // Server address
 "Server 2's data upload server address", // the address of the data upload server
 "/api/v1/mop/", // Server interface request routing prefix
 "", // SDK fingerprint
 "encryption method" // encryption method, national:SM, md5: MD5
);
storeConfigs. add(storeConfig2);
FinAppConfig config = new FinAppConfig. Builder()
 .setFinStoreConfigs(storeConfigs) // A collection of server information
 .build();

::::

2. Itens de configuração

FinAppConfig configuration items

java
/**
* :: Configuration information for the applet framework
*/
public class FinAppConfig {

 /**
* sdkKey, issued through the Vantaa Applet Open Platform
*/
 @NonNull
 private String sdkKey =  "" ;
 /**
* :: sdkSecret, issued through the Vantaa Widget Open Platform
*/
 @NonNull
 private String sdkSecret =  "" ;
 /**
* :: SDK fingerprinting
*/
 @NonNull
 private String sdkFingerprint =  "" ;
 /**
* Server address
*/
 @NonNull
 private String apiUrl =  "" ;
 /**
* Data upload server address
*/
 private String apmServer =  "" ;
 /**
* Server interface request routing prefix
*/
 @NonNull
 @Deprecated
 private String apiPrefix =  "" ;
 /**
* User ID
*/
 private String userId;
 /**
* :: Customised product identification
*/
 private String productIdentification =  "" ;
 /**
* Jwt
*/
 @Deprecated
 private String jwt;
 /**
* Access Token
*/
 @Deprecated
 private String accessToken;
 /**
* Is it currently in Debug mode
*/
 private boolean isDebugMode;
 /**
* Is jwt automatically added when Glide loads an image
*/
 @Deprecated
 private boolean isGlideWithJWT;
 /**
* UI configuration
*/
 private UIConfig uiConfig;
 /**
* APM statistical extension information
*/
 private Map< String, Object> apmExtendInfo;
 /**
* Encryption method, cc:SM, md5: MD5
*/
 @NonNull
 private String encryptionType;
 /*
* :: Whether the server is required to encrypt the returned data
*/
 private boolean encryptServerData;
 /**
* Whether to disable initiating runtime permission requests,
default no
*/
 private boolean disableRequestPermissions;
 /**
* Domains that require cookies to be removed
*/
 private List< String> needToRemoveCookiesDomains;
 /**
* Whether to disable the Tbs SDK
*/
 private boolean disableTbs;
 /**
* Custom WebView UserAgent
*/
 private String customWebViewUserAgent;
 /**
* WebView mixed content mode
*/
 private int webViewMixedContentMode;
 /**
 * :: Number of scheduled batch updates of applets
*/
 private int appletIntervalUpdateLimit;
 /**
* The maximum number of applets that can be run simultaneously. If
more than this number of applets are opened, the earliest opened applet
will be recalled, but can still be reopened
*/
 private int maxRunningApplet;
 /**
* :: Collection of information on the configuration of the applet
marketplace
*/
 @NonNull
 private List< FinStoreConfig> finStoreConfigs;
 /**
* :: Whether to start foreground services when the applet is
running in the foreground
*/
 private ForegroundServiceConfig foregroundServiceConfig;
 /**
* :: Applet is bound to app process, app is killed, applet is
closed simultaneously
*/
 private boolean bindAppletWithMainProcess;
 /**
* Text for closing the applet after the app is killed
*/
 private String killAppletProcessNotice;
 /**
* Applet text, you can replace the  "applet"  prompt in the sdk with
another name
*/
 private String appletText;
 /**
* :: Whether to compress the requested data when requesting the
back-end interface
*/
 private boolean enableApmDataCompression;
 /**
* Whether to disable calls to the applet API for getting supervise
information {@link
com.finogeeks.lib.applet.api.supervise.SuperviseModule#API_GET_SUPERVIS
E_INFO}.
* Calling is allowed by default.
*/
 private boolean disableGetSuperviseInfo;
 /**
* Whether to automatically allow [applet level] permissions for
applet applications
* If allowed automatically, no authorisation pop-up box will
appear on application.
*/
 private boolean appletAutoAuthorize;
 /**
* Whether to open the applet vConsole debug button.
*/
 private boolean enableAppletDebug;
 /**
* Priority of the screen recording configuration item, default
GLOBAL
*/
 private FinAppConfigPriority screenShotPriority;
 /**
* Whether to allow screen recording, default
*/
 private boolean enableScreenShot;
 /**
* Priority of the watermark configuration item, default GLOBAL
*/
 private FinAppConfigPriority watermarkPriority;
 /**
* Whether to turn on watermarking, not by default
*/
 private boolean enableWatermark;
 /**
* Configuration of the specified applet AppId
*/
 private transient IAppletConfigFactory appletConfigFactory;
 /**
* WatermarkView constructor
*/
 private String watermarkFactoryClass;
 /**
* Request header configuration priority
*/
 private FinAppConfigPriority headerPriority;
 /**
* the default header passed in by interfaces such as request
*/
 private Map< String, String> header;
 /**
 * :: Offline subpackage package file fetching class implemented by
the host app
*/
 private String offlinePackageFactoryClass;
 /**
* :: Applet jump handling
*/
 private transient NavigateDelegate navigateDelegate;
 /**
* The maximum depth of the applet page stack, while 0 means there
is no depth limit.
*/
 private int pageCountLimit;
 /**
* Minimum supported Android SDK version
*/
 private int minAndroidSdkVersion = Build. VERSION_CODES. LOLLIPOP;
 /**
* Logging levels
*/
 private XLogLevel logLevel;
 /**
* Maximum log file cache time in seconds.
*
* The minimum cannot be less than 1 day, i.e. not less than 1 * 24
* 60 * 60 seconds.
*/
 private long logMaxAliveSec = -1;
 /**
* XLog log file path
*/
 private String xLogDir = null;
 /**
* Offline applet AccountInfo factory class
*/
 private String offlineAccountInfoClass = null;

}

Exemplo de configuração do finAppConfig

kotlin
val config = FinAppConfig.
 .setDebugMode(true)
 .setLogLevel(XLogLevel.LEVEL_VERBOSE)
 .setEnableAppletDebug(true)
 .setUiConfig(uiConfig)
 .setApmExtendInfo(apmExtendInfo)
 .setDisableRequestPermissions(false)
 .setNeedToRemoveCookiesDomains(listOf( "" ))
 .setDisableTbs(false)
 .setAppletIntervalUpdateLimit(3)
 .setMaxRunningApplet(5)
 .setPageCountLimit(5)
 .setBindAppletWithMainProcess(true)
 .setWebViewMixedContentMode(MIXED_CONTENT_NEVER_ALLOW)
 .setFinStoreConfigs(finStoreConfigs)
 .setEnableApmDataCompression(true)
 .setDisableGetSuperviseInfo(true)
 .setCustomWebViewUserAgent( "android 7.1.1" )
 .setUserId( "13286836062" )
.setProductIdentification( "happy" )
 .setMinAndroidSdkVersion(Build.VERSION_CODES.LOLLIPOP)
 .build()
 FinAppClient.init(application, config, object :
FinCallback<Any?> {

setProductIdentification Ised pela chave após a versão 2.38.0, isso Deve -se notar que chapers em branco e chappers não podem ser usado em productIdentification , O que setProductIdentification É Usado para quando você usa setProductIdentification Para personalizar o Identificação do produto, você precisa personalizar o arquivo de caminhos, pegar o Valor do produto de produto de happy Como Anample, adicione um novo XML arquivo chamado fin_applet_custom_provider_paths no caminho res/xml, o O nome do arquivo não pode ser alterado.

xml
<! -- The file name must be fin_applet_custom_provider_paths.xml, for same-name replacement -->
<?xml version= "1.0"  encoding= "utf-8" ? >
<paths xmlns:android= "http://schemas.android.com/apk/res/android" >
<files-path
name= "happy_uri" 
path= "happy" 
/>
</paths>

Após as configurações acima, um arquivo com o caminho /internal storeage/packageName/files/happy/hello.jpg tem um URI correspondente de Uri de Conteúdo: //com.finogeeks.finosprite.applet.provider/ happy_uri/hello.jpg.

UIConfig configuration items

java
 /**
* :: UI configuration
*/
 public static class UIConfig {
 /**
* Whether the back button is always displayed when the
navigation bar is the default navigation bar
*/
 private boolean isAlwaysShowBackInDefaultNavigationBar;
 /**
* Gravity of the navigation bar title relative to the parent
control
*/
 private int navigationBarTitleTextLayoutGravity = Gravity;
 /**
* Navigation bar header text style
*/
 @StyleRes
 private int navigationBarTitleTextAppearance;
 /**
* Whether to clear the background of the navigation buttons in
the navigation bar
*/
 private boolean isClearNavigationBarNavButtonBackground;
 /**
* :: Whether to hide the  "Feedback & Complaints"  menu entry in
the  "More"  menu
*/
 private boolean isHideFeedbackAndComplaints;
 /**
* Whether to hide the  "Back to Home"  button on the navigation
bar
*/
 private boolean isHideBackHome;
 /**
* Priority of the  "Back to Home"  button configuration item on
the navigation bar, default GLOBAL
*/
 private FinAppConfigPriority isHideBackHomePriority =
FinAppConfigPriority. global;
 /**
* Whether to hide the  "Forward"  button in the  "More"  menu
*/
 private boolean isHideForwardMenu;
 /**
* Whether to hide the  "Settings"  button in the  "More"  menu
*/
 private boolean isHideSettingMenu;
 /**
* :: Whether to hide the  "Re-enter applet"  button in the
 "More"  menu
*/
 private boolean isHideRefreshMenu;
 /**
 * :: Whether to hide the close button in the navigation bar
during the loading of the applet (the applet service layer has
not yet been loaded successfully and the base library has not yet
passed the applet configuration information to the SDK)
*/
 private boolean hideTransitionCloseButton;
 /**
 * :: Disable the side-swipe close applet gesture
*/
 private boolean disableSlideCloseAppletGesture;
 /**
*  "More"  menu style
*/
 @MoreMenuStyle
 private int moreMenuStyle;
 /**
* Capsule button configuration
*/
 private CapsuleConfig capsuleConfig = new CapsuleConfig();
 private FloatWindowConfig floatWindowConfig = new
FloatWindowConfig();
 /**
* Loading page callback Class
*/
 private String loadingLayoutCls;
 /**
* :: Dark mode
*/
 private boolean autoAdaptDarkMode;
 /**
* Navigation bar back to home button configuration
*/
 private NavHomeConfig navHomeConfig = new NavHomeConfig();
 }

Exemplo de configuração do uiconfig

 val uiConfig = UIConfig()
 uiConfig.isHideBackHome = true
 uiConfig.isHideForwardMenu = false
 uiConfig.isHideFeedbackAndComplaints = false
 uiConfig.isHideSettingMenu = false
 uiConfig.navigationBarTitleTextAppearance
 uiConfig.moreMenuStyle = UIConfig.MORE_MENU_DEFAULT
 val config = FinAppConfig.
 .setUiConfig(uiConfig)

CapsuleConfig configuration items

kotlin
val uiConfig = UIConfig()
uiConfig.setCapsuleConfig(CapsuleConfig())

Propriedades de configuração da cápsula

java
public static class CapsuleConfig {
 /**
* The width of the capsule view in the top right corner, the
default value is 88
*
*/
 public float capsuleWidth = 88;
 /**
* The height of the capsule view in the top right corner, the
default value is 32
*
*/
 public float capsuleHeight = 32;
 /**
* Right distance from top right capsule view
*/
 public float capsuleRightMargin = 7;
 /**
* The radius of the rounded corners of the capsule view in the
upper right corner, the default value is 5
*
*/
 public float capsuleCornerRadius = 5;
 /**
* The width of the border of the capsule view in the top right
corner, the default value is 0.8
*
*/
 public float capsuleBorderWidth = 1f;
 /**
* Capsule background colour light
*/
 public int capsuleBgLightColor = 0x33000000;
 /**
* Capsule background colour dark
*/
 public int capsuleBgDarkColor = 0x80ffffff;
 /**
* Lighter colour for the border of the capsule view in the top
right corner
*
*/
 public int capsuleBorderLightColor = 0x80ffffff;
 /**
* Dark colour of the border of the capsule view in the top
right corner
*
*/
 public int capsuleBorderDarkColor = 0x26000000;
 /**
* Capsule divider light colour
*/
 public int capsuleDividerLightColor = 0x80ffffff;
 /**
* Capsule divider dark colour
*/
 public int capsuleDividerDarkColor = 0x26000000;
 /**
* Image object of the light-coloured more button in the
capsule, if not passed, the default icon will be used
*
*/
 public int moreLightImage = R. drawable. miniapps_more_light;
 /**
* Image object for the darker more buttons in the capsule, if
not passed, the default icon will be used
*
*/
 public int moreDarkImage = R. drawable. miniapps_more_dark;
 /**
* More buttons in the capsule with a width equal to the height
*
*/
 public float moreBtnWidth = 32;
 /**
* Left margin of the More button in the capsule
*
*/
 public float moreBtnLeftMargin = 6;
 /**
* Image object of the light-coloured more button in the
capsule, if not passed, the default icon will be used
*
*/
 public int closeLightImage = R. drawable. miniapps_close_light;
 /**
* Image object for the darker more buttons in the capsule, if
not passed, the default icon will be used
*
*/
 public int closeDarkImage = R. drawable. miniapps_close_dark;
 /**
* Width of the close button in the capsule, equal in height to
width
*
*/
 public float closeBtnWidth = 32;
 /**
* Left distance of the close button in the capsule
*
*/
 public float closeBtnLeftMargin = 6;
}

Exemplo de uma cápsula de configuração

kotlin
uiConfig.capsuleConfig.apply {
 capsuleWidth = 86f
 capsuleHeight = 31f
 capsuleRightMargin = 15f
 capsuleCornerRadius = 15.5f
 capsuleBorderWidth = 0.5f
 capsuleBgLightColor = Color.TRANSPARENT
 capsuleBgDarkColor = Color.TRANSPARENT
 capsuleBorderLightColor = Color.parseColor( "#88ffffff" )
 capsuleBorderDarkColor = Color.parseColor( "#a5a9b4" )
 moreLightImage = R.drawable.more_light
 moreDarkImage = R.drawable.more_dark
 moreBtnWidth = 25f
 moreBtnLeftMargin = 11f
 closeLightImage = R.drawable.close_light
 closeDarkImage = R.drawable.close_dark
 closeBtnWidth = 25f
 closeBtnLeftMargin = 9f
 capsuleDividerLightColor = Color.parseColor( "#88ffffff" )
 capsuleDividerDarkColor = Color.parseColor( "#a5a9b4" )
}
kotlin
val uiConfig = UIConfig()
uiConfig.setNavHomeConfig(NavHomeConfig())

As condições atuais para o botão de volta ao lar são (Sujeito a ambos sendo atendidos). "

  1. O estilo de barra de navegação padrão (não personalizado) é usuário. "
  2. Não é a página inicial ou a página do TabBar (conforme definido em App.json). "
  3. é a página inferior da pilha da página. " Applets pode ligar para HideHomeButton () em Onsshow para esconder manualmente as costas Botão inicial.

Barra de navegação de volta aos atributos do estilo do botão home

java
public static class NavHomeConfig {
 /**
* Light icon for the navigation bar back to home button, if not
passed, the default icon will be used
*/
 public int lightImage = R. drawable. miniapps_home_light;
 /**
* Light icon for the navigation bar back to home button, if not
passed, the default icon will be used
*/
 public int darkImage = R. drawable. miniapps_home_dark;
 /**
* Back to home button width, default 44
*/
 public float width = 44;
 /**
* Back to home button height, default 32
*/
 public float height = 32;
 /**
* Left margin of the Back to Home button, default 7
*/
 public float leftMargin = 7;
 /**
* Home button border rounding radius, default 5
*/
 public float cornerRadius = 5;
 /**
* Back to home button border width, default 1
*/
 public float borderWidth = 1;
 /**
* Back to home button light border colour, default 0X80FFFFFF
*/
 public int borderLightColor = 0x80ffffff;
 /**
* Back to home button dark border colour, default 0X26000000
*/
 public int borderDarkColor = 0x26000000;
 /**
* Back to home button light background, default 0x33000000
*/
 public int bgLightColor = 0x33000000;
 /**
* Back to home button dark background, default 0x33000000
*/
 public int bgDarkColor = 0x80ffffff;
}

Exemplo de configurar o estilo do botão traseiro para a navegação

bar

kotlin
uiConfig.navHomeConfig.apply {
 width = 43f
 height = 31f
 leftMargin = 15f
 cornerRadius = 15.5f
 borderWidth = 0.5f
 bgLightColor = Color.TRANSPARENT
 bgDarkColor = Color.TRANSPARENT
 borderLightColor = Color.parseColor( "#88ffffff" )
 borderDarkColor = Color.parseColor( "#a5a9b4" )
 lightImage = R.drawable.home_light
 darkImage = R.drawable.home_dark
}

Configure applets para executar em janelas flutuantes

Em alguns dispositivos de tela grande, o applet pode ser configurado para executar como um janela flutuante. Ao funcionar como uma janela flutuante, o applet é fixo No modo vertical, a posição e o tamanho da janela flutuante podem ser Configurado, e as páginas abaixo da flowow não são internet // Depois de definir o modo de onda, substituir o Finalthem FINAPLETTRANSLUCENTEME NO AMPLOMES.XML ao mesmo tempo

xml
<! -- Hover mode needs to override FinAppletTheme theme as
FinAppletTranslucentTheme -->
< style name= "FinAppletTheme"  parent= "@style/FinAppletTranslucentTheme" 
/>

Introdução às propriedades de configuração de janelas flutuantes

kotlin
 public static class FloatWindowConfig {
 public boolean floatMode = false;
 public int x;
 public int y;
 public int width;
 public int height;
 }

Exemplo de uma configuração de janela flutuante

kotlin
uiConfig.floatWindowConfig.apply {
 floatMode = false
 width = 800
 height = 1400
 x = application.screenWidth() / 2 - width / 2
 y = application.screenHeight() / 2 - height / 2
 }

Defina o número máximo de applets que podem ser executados

Esta interface permite definir o número máximo de applets que podem ser executado. Quando mais applets forem subidos do que o número máximo, o primeiro Applet aberto será reciclado.

Nota

O número máximo de applets executáveis ​​é 5 por padrão e pode ser definido No intervalo 1-5. números definidos <= 0 ou> 5 não entram em vigor

kotlin
val config = FinAppConfig.
 .setSdkKey( "SDK Key" )
 .setSdkSecret( "SDK Secret" )
 .setMaxRunningApplet(3) // set the maximum number of applets that
can be run
 .build()

FinAppClient.init(application, config, object : FinCallback<Any?> {})

Configure os serviços em primeiro plano para manter o aplicativo funcionando

Quando o applet é optado, o aplicativo entra no plano de fundo e é executado. AT. Este ponto o aplicativo pode ser morto pelo sistema. Ele pode ser configurado para Mantenha o aplicativo em funcionamento sem ser morto pelo sistema iniciando um Serviço de primeiro plano

kotlin
val config = FinAppConfig.
 .setSdkKey(BuildConfig.SDK_KEY)
 .setSdkSecret(BuildConfig.SDK_SECRET)
 .setForegroundServiceConfig(
 FinAppConfig.ForegroundServiceConfig(
 true, //whether to enable frontend services
 R.drawable.ic_launcher, //icon for frontend services
  "Applet is running" , // title of the foreground service
  "" ,
 notificationChannelId, // notificationChannelId
 notificationChannelName, // the name of the notification
channel
 notificationChannelDesc, // Introduction to the
notification channel
 )
 )
 .build()

FinAppClient.init(application, config, object : FinCallback<Any?> {})

Defina o processo de applet para fechar onde

Por padrão, os applets ainda podem ser executados de forma independente quando o aplicativo principal Processo está fechado. Isso pode ser combinado com o processo de applet sendo Fechado quando o processo de aplicativo é fechado ou morto

kotlin
val config = FinAppConfig.
 .setSdkKey(BuildConfig.SDK_KEY)
 .setSdkSecret(BuildConfig.SDK_SECRET)
 .setBindAppletWithMainProcess(true) //when the main
process is closed the applet process is also closed
 .setKillAppletProcessNotice("The APP has been closed,
the applet cannot be used alone, please reopen the APP before using the
applet.")
 .build()
FinAppClient.init(application, config, object : FinCallback<Any?> {})

Configurar o modo de depuração de applet

val config = FinAppConfig.
 // Other configuration items omitted
 .setEnableAppletDebug(true)
 .build()
 
FinAppClient.init(application, config, object : FinCallback<Any?> {})

Se deve habilitar o modo de depuração do GWALT, defina como True e todos os applets Mostrará vconsole, se definido como false, o modo de depuração pode ser ativado para Desenvolvimento, experiência e versões de visualização de IDE através do botão de depuração nos mais homens