AdMob-based advertising publishing method, device, computer equipment and storage medium
By preloading the ads after the program is started and loading new ads after the ads are consumed, the problems of time-consuming and display failure in the prior art are solved, and more efficient advertising display and higher success rates are achieved.
Patent Information
- Application Number
- CN202311479787.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-08
- Publication Date
- 2025-02-07
- Estimated Expiration
- 2043-11-08
AI Technical Summary
Existing AdMob-based ad publishing methods require the ad to be loaded before each display ad, resulting in time-consuming operations increasing waiting time, and unloaded ad calls to the display interface will cause failure.
By preloading the first ad after the program is started and loading a new ad after the ad is consumed, use the ad preload function to call the load function of the ad SDK for the ad loading, and set the display function after loading to determine whether the ad is loaded successfully. Finally, When the ad is loaded successfully, the ad display function is called for display.
It realizes preloading of ads, avoids timeout waiting, saves time waiting for ads to load, and improves the success rate of ad display.
Smart Images

Figure CN117435835B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer software technology, and in particular to an advertisement publishing method, device, computer equipment and storage medium based on AdMob. Background Art
[0002] AdMob is a mobile advertising SDK provided by Google. It can embed ads in mobile applications and earn revenue. It is often used to display ads when loading game levels, or to get extra coins by watching ads. The common steps for using ads are: initialize SDK->load ads->display ads. However, this conventional method still has certain disadvantages. For example, ads need to be loaded before each ad display, and loading ads is a time-consuming operation, so it will increase the extra waiting time. In addition, if the ad display interface is called before the ad is fully loaded, the ad display will fail. Summary of the invention
[0003] The embodiments of the present invention provide an advertisement publishing method, apparatus, computer equipment and storage medium based on AdMob, aiming to preload advertisements and improve the success rate of advertisement publishing and display.
[0004] In a first aspect, an embodiment of the present invention provides an advertisement publishing method based on AdMob, comprising:
[0005] Acquire the advertisement SDK data to be released based on AdMob, initialize the advertisement SDK data and create an advertisement tool class according to the advertisement SDK data, and configure parameters for the advertisement tool class; wherein the parameters include an advertisement unit id;
[0006] Setting an advertisement preloading function, and using the advertisement preloading function to call the load function of the advertisement SDK data, so as to load the advertisement based on the advertisement unit ID through the load function;
[0007] Setting a post-load display function, and using the post-load display function to determine whether the advertisement is loaded successfully;
[0008] An advertisement display function is set, and when it is determined that the advertisement has been loaded successfully, the advertisement display function is called to publish and display the advertisement.
[0009] In a second aspect, an embodiment of the present invention provides an advertisement publishing device based on AdMob, comprising:
[0010] A data acquisition unit, used to acquire the advertisement SDK data to be published based on AdMob, initialize the advertisement SDK data and create an advertisement tool class according to the advertisement SDK data, and configure parameters for the advertisement tool class; wherein the parameters include an advertisement unit id;
[0011] An advertisement loading unit, used to set an advertisement preloading function, and use the advertisement preloading function to call the load function of the advertisement SDK data, so as to load the advertisement based on the advertisement unit ID through the load function;
[0012] A loading judgment unit, used to set a post-loading display function and use the post-loading display function to judge whether the advertisement is loaded successfully;
[0013] The advertisement publishing unit is used to set an advertisement display function, and when it is determined that the advertisement is loaded successfully, the advertisement display function is called to publish and display the advertisement.
[0014] In a third aspect, an embodiment of the present invention provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the AdMob-based advertising publishing method as described in the first aspect is implemented.
[0015] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the AdMob-based advertising publishing method as described in the first aspect is implemented.
[0016] The embodiment of the present invention provides an advertisement publishing method, device, computer equipment and storage medium based on AdMob, the method comprising: obtaining advertisement SDK data to be published based on AdMob, initializing the advertisement SDK data and creating an advertisement tool class according to the advertisement SDK data, and configuring parameters for the advertisement tool class; wherein the parameters include an advertisement unit id; setting an advertisement preloading function, and using the advertisement preloading function to call the load function of the advertisement SDK data, so as to load the advertisement based on the advertisement unit id through the load function; setting a post-loading display function, and using the post-loading display function to determine whether the advertisement is loaded successfully; setting an advertisement display function, and calling the advertisement display function to publish and display the advertisement when it is determined that the advertisement is loaded successfully. The embodiment of the present invention first creates an advertisement tool class according to the acquired advertisement SDK data, and then sets the corresponding advertisement preloading function, post-loading display function and advertisement display function, so as to realize advertisement preloading through these multiple functions, and can avoid timeout waiting, that is, save the time of waiting for advertisement loading, and improve the success rate of advertisement display. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying any creative work.
[0018] Figure 1 A schematic diagram of a flow chart of an advertisement publishing method based on AdMob provided in an embodiment of the present invention;
[0019] Figure 2 A schematic block diagram of an AdMob-based advertisement publishing device provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0020] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0021] It should be understood that when used in this specification and the appended claims, the terms "include" and "comprises" indicate the presence of described features, integers, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or combinations thereof.
[0022] It should also be understood that the terms used in this specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in the specification of the present invention and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.
[0023] It should be further understood that the term "and / or" used in the present description and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0024] See below Figure 1 , Figure 1 A schematic flow chart of an advertisement publishing method based on AdMob provided by an embodiment of the present invention specifically includes steps S101 to S104.
[0025] S101, obtaining advertisement SDK data to be published based on AdMob, initializing the advertisement SDK data and creating an advertisement tool class according to the advertisement SDK data, and configuring parameters for the advertisement tool class; wherein the parameters include an advertisement unit id;
[0026] S102, setting an advertisement preloading function, and using the advertisement preloading function to call the load function of the advertisement SDK data, so as to load the advertisement based on the advertisement unit ID through the load function;
[0027] S103, setting a post-loading display function, and using the post-loading display function to determine whether the advertisement is loaded successfully;
[0028] S104: setting an advertisement display function, and calling the advertisement display function to publish and display the advertisement when it is determined that the advertisement has been loaded successfully.
[0029] This embodiment first creates an advertising tool class based on the acquired advertising SDK data, and then sets the corresponding advertising preloading function, post-loading display function, and advertising display function, so as to realize advertising preloading through these multiple functions and avoid timeout waiting, that is, save the time waiting for advertising loading and improve the success rate of advertising display.
[0030] It should be noted that, in this embodiment, the ad preloading mechanism (i.e., preloading the ads) is to load the first ad after the program is started, and load new ads after the ads are consumed, so that the preloaded ads can be used directly where the ads need to be displayed, thereby reducing the time users have to wait for the ads to load. In addition, in addition to the ad unit ID, the parameters also include an ad loading timeout, which is used to indicate the maximum time to wait for the ad to load when displaying the ad; and an ad callback, which is used to call back the loading status and display status of the ad, including successful ad loading, failed ad loading, successful ad display, failed ad display, the ad being clicked, the ad being closed, etc. For example, in some scenarios where the demand for the success rate of ad display is relatively high, such as when users watch incentive ads to obtain coins, the ad loading timeout can improve the success rate of ad display by giving sufficient waiting time for loading so that the ad is displayed after loading is complete.
[0031] In one embodiment, the initializing the advertising SDK data and creating an advertising tool class according to the advertising SDK data, and configuring parameters for the advertising tool class include:
[0032] Set the callback class Callback to call back the ad loading status and ad display status through the callback class Callback;
[0033] Set up the inner class Builder and set the configuration function of related parameters in the inner class Builder;
[0034] Set the static function with and instantiate the inner class Builder through the static function with;
[0035] The advertising tool class is created based on the callback class Callback, the internal class Builder and the static function with.
[0036] When creating an advertising tool class in this embodiment, the specific configuration process is: define a callback class Callback, which is used to call back the advertisement loading status and advertisement display status. The callback function includes:
[0037] onAdLoaded, indicating that the callback ad has been loaded;
[0038] onAdFailToLoad: callback indicates that the ad loading failed;
[0039] onAdClicked, indicating that the callback ad is clicked;
[0040] onAdDismissed, indicating that the callback ad has been closed;
[0041] onAdFailedToShow: indicates that the callback ad display fails;
[0042] onAdShowed: indicates that the callback ad display is successful.
[0043] Define the inner class Builder and define the configuration functions of related parameters in Builder, including:
[0044] setAdsId(id: String): Builder, this function passes in an ad unit id and saves it to the Builder, and returns the Builder object;
[0045] setLoadTimeOut(timeout: Long): Builder, this function passes in a loading timeout and saves it to the Builder, and returns the Builder object;
[0046] setCallback(callback: Callback): Builder. This function passes in an advertisement callback class defined in S1-1 and saves it to the Builder, and returns the Builder object.
[0047] The benefit of returning Builder is that it facilitates chain calls and continuous configuration of multiple parameters.
[0048] Define a static function with, in which the Builder object is instantiated. The static function can be called directly by the class name, making it convenient for other classes to obtain the Builder object and configure related parameters.
[0049] In one embodiment, the setting of the advertisement preloading function and using the advertisement preloading function to call the load function of the advertisement SDK data so as to load the advertisement based on the advertisement unit ID through the load function includes:
[0050] Declare a flag bit for whether the advertisement is in a loading state, and set the initial value of the flag bit to false; and declare an advertisement object, and set the initial value of the advertisement object to null to indicate that the advertisement is not loaded;
[0051] After setting the ad preloading function, get the current flag and ad object;
[0052] If the flag at the current moment is false or the advertisement object is empty, the load function is called to load the advertisement.
[0053] When preloading advertisements, this embodiment first declares a flag to determine whether the advertisement is being loaded, and its initial value is false. At the same time, an advertisement object is declared, and its initial value is empty. If the advertisement object is not empty, it means that the advertisement has been loaded. After declaring the flag and the advertisement object, if it is detected that the advertisement is being loaded, or the advertisement object is not empty, no operation is performed. Otherwise, the load function of the advertisement SDK is called, and the configured advertisement unit id is passed in, and the load flag is set to true. The load function will return information on whether the advertisement is loaded successfully or failed.
[0054] In one embodiment, the step of setting an advertisement preloading function and using the advertisement preloading function to call a load function of the advertisement SDK data so as to load the advertisement based on the advertisement unit ID through the load function further includes:
[0055] Initiate an ad request to the cloud through the adUnitId parameter in the load function;
[0056] Receive the advertisement matching data returned by the cloud, and convert the advertisement matching data into an advertisement object;
[0057] Call back the onAdLoaded function and pass in the ad object.
[0058] In this embodiment, when the load function is called to load an ad, the configured ad unit ID is passed in and the ad loading callback is set. If the ad is loaded successfully, the loaded ad object ad is saved and the ad loading success status is called back; if the ad is loaded unsuccessfully, the ad loading failure information is called back. The ad object ad is a class defined in the ad SDK data. When the load function in the SDK is called to load the ad successfully, the ad data loaded locally is converted into the ad object ad and called back to the current class through the onAdLoaded function. The ad object ad is needed to display the ad later.
[0059] The Load function is an interface function provided by the advertising SDK and is used to load ads. Its prototype is as follows: public static void load(Context context, String adUnitId, AdRequest adRequest, AdLoadCallback loadCallback)
[0060] This function is a static function. The parameter context is the context. The parameter adUnitId is the ad unit id, which is used to request ads of a specified type, such as interstitial ads, rewarded ads, etc. The parameter adRequest is the request configuration, which can be used to configure test ads, set agents, etc. loadCallback is a loading callback class provided by the SDK. It is necessary to rewrite the onAdLoaded and onAdFailedToLoad functions. After the ad is loaded, these two functions are used to call back the ad loading success and ad loading failure information. The specific process of the Load function loading ads is as follows: First, an ad request is initiated to the cloud based on adUnitId. The request configuration is specified by adRequest. If not specified, the default configuration is used. Then, the cloud matches ads based on adUnitId. If the match is successful, the ad data is returned to the client. The client converts the ad data into the corresponding ad object, calls back the onAdLoaded function and passes in the ad object. If the match fails, an error message is returned to the client. The client calls back the onAdFailedToLoad function and passes in the error message.
[0061] It should be noted that the preloading and loading described in this embodiment are different steps. The specific difference between the two is that the loading function is provided by the advertising SDK, and the advertising data can be loaded locally through this function. The preloading function is created by this embodiment, which is a layer of encapsulation of the loading function. The preloading function will only call the loading function to load the advertisement if the advertisement is not loaded. Repeated calls to the preloading function will only load the advertisement once. New advertisements will not be loaded until the advertisement is loaded and consumed, thereby avoiding resource waste.
[0062] In one embodiment, setting a post-loading display function and using the post-loading display function to determine whether the advertisement is loaded successfully includes:
[0063] Create a coroutine and start a loading loop in the coroutine;
[0064] Based on the loading cycle, it is determined every preset cycle threshold whether the advertisement is loaded successfully, or whether the waiting time for advertisement loading exceeds a preset time threshold.
[0065] This embodiment takes into account that if the loaded advertisement is directly published and displayed, the advertisement display may fail due to the advertisement not being loaded completely, so the display function showAfterLoaded after loading is defined. If the advertisement has been loaded, or the advertisement loading timeout parameter is not set, the display advertisement can be published directly. If the advertisement is not loaded, or the advertisement loading timeout parameter is set, a coroutine running in the child thread is started, and a loop is started in the coroutine, and every preset loop threshold (500ms) is used to determine whether the advertisement has been loaded or whether the waiting time has timed out. If the advertisement has been loaded or the waiting has timed out, the loop is exited, the coroutine scope is switched to the main thread, and the display advertisement is published directly. Here, for the time-consuming operations in the Android end, the child thread needs to be started for execution, and the UI interface update operation needs to be executed in the main thread. The coroutine can be used to quickly switch to the child thread to execute the operation of waiting for the advertisement to be loaded. After loading is completed or loading has timed out, it is necessary to switch to the main thread to display the advertisement.
[0066] In one embodiment, the setting of the advertisement display function and calling the advertisement display function to publish the advertisement when it is determined that the advertisement has been loaded successfully includes:
[0067] Set the advertisement display function to public abstract void show(Activity activity);
[0068] Call the setFullScreenContentCallback function of the ad object to set the ad display callback to monitor the ad display status;
[0069] Use the activity parameter to publish and display advertisements.
[0070] In this embodiment, the advertisement display function is specifically public abstract void show(Activity activity), where the parameter activity is the activity page in the program where the advertisement needs to be displayed. However, before displaying, the setFullScreenContentCallback function of the advertisement object ad needs to be called to set the advertisement display callback in order to monitor the advertisement display status.
[0071] In one embodiment, the AdMob-based advertising release further includes:
[0072] When it is determined that the advertisement loading fails, the advertisement preloading function is called to reload the advertisement until the advertisement loading succeeds or the advertisement loading time exceeds a preset time threshold.
[0073] In this embodiment, when determining whether an ad has been loaded, if the ad object ad is empty, it means that the ad has not been loaded. If the ad has not been loaded, the callback class function onAdFailedToShow is called back, and then the ad preload function preload is called to reload the ad. The advantage of this is that even if the ad fails to be displayed due to the ad being loaded, the current ad will continue to be loaded, and a new ad will be loaded as a backup if the ad fails to load.
[0074] Figure 2 A schematic block diagram of an AdMob-based advertisement publishing device 200 provided in an embodiment of the present invention, the device 200 includes:
[0075] The data acquisition unit 201 is used to acquire the advertisement SDK data to be released based on AdMob, initialize the advertisement SDK data and create an advertisement tool class according to the advertisement SDK data, and configure parameters for the advertisement tool class; wherein the parameters include an advertisement unit id;
[0076] The advertisement loading unit 202 is used to set an advertisement preloading function, and use the advertisement preloading function to call the load function of the advertisement SDK data, so as to load the advertisement based on the advertisement unit ID through the load function;
[0077] The loading judgment unit 203 is used to set a post-loading display function and use the post-loading display function to judge whether the advertisement is loaded successfully;
[0078] The advertisement publishing unit 204 is used to set an advertisement display function, and when it is determined that the advertisement is loaded successfully, the advertisement display function is called to publish and display the advertisement.
[0079] In one embodiment, the data acquisition unit 201 includes:
[0080] The callback class setting unit is used to set the callback class Callback, so as to call back the advertisement loading status and advertisement display status through the callback class Callback;
[0081] The inner class setting unit is used to set the inner class Builder and set the configuration function of related parameters in the inner class Builder;
[0082] The static function setting unit is used to set the static function with and instantiate the internal class Builder through the static function with;
[0083] The tool class creation unit is used to create the advertisement tool class based on the callback class Callback, the internal class Builder and the static function with.
[0084] In one embodiment, the advertisement loading unit 202 includes:
[0085] a declaration unit, used to declare a flag bit for indicating whether the advertisement is in a loading state, and set the initial value of the flag bit to false; and to declare an advertisement object, and set the initial value of the advertisement object to null to indicate that the advertisement is not loaded;
[0086] A flag acquisition unit, used to acquire the flag and advertisement object at the current moment after setting the advertisement preloading function;
[0087] The function calling unit is used to call the load function to load the advertisement if the flag bit at the current moment is false or the advertisement object is empty.
[0088] In one embodiment, the advertisement loading unit 202 further includes:
[0089] The request initiating unit is used to initiate an advertising request to the cloud through the adUnitId parameter in the load function;
[0090] A data conversion unit, configured to receive the advertisement matching data returned by the cloud, and convert the advertisement matching data into an advertisement object;
[0091] The callback input unit is used to call back the onAdLoaded function and pass in the ad object.
[0092] In one embodiment, the loading determination unit 203 includes:
[0093] A coroutine loop unit, used to create a coroutine and start a loading loop in the coroutine;
[0094] The cycle determination unit is used to determine whether the advertisement is loaded successfully or whether the waiting time for advertisement loading exceeds a preset time threshold based on the loading cycle and every preset cycle threshold.
[0095] In one embodiment, the advertisement publishing unit 204 includes:
[0096] A function setting unit, used to set the advertisement display function to public abstract void show(Activity activity);
[0097] The status monitoring unit is used to call the setFullScreenContentCallback function of the advertisement object to set the advertisement display callback to monitor the advertisement display status;
[0098] The parameter display unit is used to display advertisements using parameter activities.
[0099] In one embodiment, the AdMob-based advertisement publishing device 200 further includes:
[0100] The reloading unit is used to call the advertisement preloading function to reload the advertisement when it is determined that the advertisement loading fails, until the advertisement loading is successful or the advertisement loading time exceeds a preset time threshold.
[0101] Since the embodiments of the apparatus part correspond to the embodiments of the method part, please refer to the description of the embodiments of the method part for the embodiments of the apparatus part, which will not be repeated here.
[0102] The embodiment of the present invention further provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed, the steps provided in the above embodiment can be implemented. The storage medium may include: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes.
[0103] The embodiment of the present invention also provides a computer device, which may include a memory and a processor, wherein a computer program is stored in the memory, and when the processor calls the computer program in the memory, the steps provided in the above embodiment may be implemented. Of course, the computer device may also include various network interfaces, power supplies and other components.
[0104] The various embodiments in the specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same and similar parts between the various embodiments can be referred to each other. For the system disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of this application, several improvements and modifications can be made to the present application, and these improvements and modifications also fall within the scope of protection of the claims of this application.
[0105] It should also be noted that, in this specification, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprises", "comprising" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the statement "comprising a ..." does not exclude the presence of other identical elements in the process, method, article or device including the element.
Claims
1. An advertisement publishing method based on AdMob, characterized in that: include: Acquire the advertisement SDK data to be released based on AdMob, initialize the advertisement SDK data and create an advertisement tool class according to the advertisement SDK data, and configure parameters for the advertisement tool class; wherein the parameters include an advertisement unit id; An advertisement preloading function is set, and the load function of the advertisement SDK data is called by using the advertisement preloading function, so as to load advertisements based on the advertisement unit id through the load function; wherein, preloading advertisements means loading the first advertisement after the program is started, and loading new advertisements after the advertisements are consumed, so that the preloaded advertisements can be directly used where the advertisements need to be displayed; Setting a post-load display function, and using the post-load display function to determine whether the advertisement is loaded successfully; Setting an advertisement display function, and calling the advertisement display function to publish and display the advertisement when it is determined that the advertisement has been loaded successfully; The initializing the advertising SDK data and creating an advertising tool class according to the advertising SDK data, and configuring parameters for the advertising tool class, include: Set the callback class Callback to call back the ad loading status and ad display status through the callback class Callback; the callback function includes: onAdLoaded, indicating that the callback ad has been loaded; onAdFailToLoad: callback indicates that the ad loading failed; onAdClicked, indicating that the callback ad is clicked; onAdDismissed, indicating that the callback ad has been closed; onAdFailedToShow: indicates that the callback ad display fails; onAdShowed: indicates that the callback ad display is successful; Set the inner class Builder and set the configuration function of related parameters in the inner class Builder; the configuration function includes: setAdsId(id: String): Builder, this function passes in an ad unit id and saves it to the Builder, and returns the Builder object; setLoadTimeOut(timeout: Long): Builder, this function passes in a loading timeout and saves it to the Builder, and returns the Builder object; setCallback(callback: Callback): Builder. This function passes in an advertisement callback class defined in S1-1 and saves it to the Builder, and returns the Builder object. Set the static function with and instantiate the inner class Builder through the static function with; The advertising tool class is created based on the callback class Callback, the internal class Builder and the static function with; The step of setting an advertisement display function and calling the advertisement display function to publish the advertisement when it is determined that the advertisement has been loaded successfully includes: Set the advertisement display function to public abstract void show(Activity activity); Call the setFullScreenContentCallback function of the ad object to set the ad display callback to monitor the ad display status; Use the activity parameter to publish and display advertisements.
2. The method for publishing advertisements based on AdMob according to claim 1, characterized in that: The step of setting an advertisement preloading function and using the advertisement preloading function to call a load function of the advertisement SDK data, so as to load the advertisement based on the advertisement unit ID through the load function, includes: Declare a flag bit for whether the advertisement is in a loading state, and set the initial value of the flag bit to false; and declare an advertisement object, and set the initial value of the advertisement object to null to indicate that the advertisement is not loaded; After setting the ad preloading function, get the current flag and ad object; If the flag at the current moment is false or the advertisement object is empty, the load function is called to load the advertisement.
3. The method for publishing advertisements based on AdMob according to claim 1, characterized in that: The step of setting an advertisement preloading function and using the advertisement preloading function to call the load function of the advertisement SDK data, so as to load the advertisement based on the advertisement unit ID through the load function, further includes: Initiate an ad request to the cloud through the adUnitId parameter in the load function; Receive the advertisement matching data returned by the cloud, and convert the advertisement matching data into an advertisement object; Call back the onAdLoaded function and pass in the ad object.
4. The method for publishing advertisements based on AdMob according to claim 1, characterized in that: The setting of the post-loading display function and using the post-loading display function to determine whether the advertisement is loaded successfully includes: Create a coroutine and start a loading loop in the coroutine; Based on the loading cycle, it is determined every preset cycle threshold whether the advertisement is loaded successfully, or whether the waiting time for advertisement loading exceeds a preset time threshold.
5. The method for publishing advertisements based on AdMob according to claim 1, characterized in that: Also includes: When it is determined that the advertisement loading fails, the advertisement preloading function is called to reload the advertisement until the advertisement loading succeeds or the advertisement loading time exceeds a preset time threshold.
6. An advertisement publishing device based on AdMob, characterized in that: include: A data acquisition unit, used to acquire the advertisement SDK data to be published based on AdMob, initialize the advertisement SDK data and create an advertisement tool class according to the advertisement SDK data, and configure parameters for the advertisement tool class; wherein the parameters include an advertisement unit id; An advertisement loading unit, used to set an advertisement preloading function, and use the advertisement preloading function to call the load function of the advertisement SDK data, so as to load advertisements based on the advertisement unit id through the load function; wherein, preloading advertisements means loading the first advertisement after the program is started, and loading new advertisements after the advertisements are consumed, so that the preloaded advertisements can be directly used where the advertisements need to be displayed; A loading judgment unit, used to set a post-loading display function and use the post-loading display function to judge whether the advertisement is loaded successfully; The advertisement publishing unit is used to set an advertisement display function and call the advertisement display function to publish and display the advertisement when it is determined that the advertisement has been loaded successfully; The data acquisition unit comprises: The callback class setting unit is used to set the callback class Callback, so as to call back the ad loading status and ad display status through the callback class Callback; the callback function includes: onAdLoaded, indicating that the callback ad has been loaded; onAdFailToLoad: callback indicates that the ad loading failed; onAdClicked, indicating that the callback ad is clicked; onAdDismissed, indicating that the callback ad has been closed; onAdFailedToShow: indicates that the callback ad display fails; onAdShowed: indicates that the callback ad display is successful; The inner class setting unit is used to set the inner class Builder and set the configuration function of related parameters in the inner class Builder; the configuration function includes: setAdsId(id: String): Builder, this function passes in an ad unit id and saves it to the Builder, and returns the Builder object; setLoadTimeOut(timeout: Long): Builder, this function passes in a loading timeout and saves it to the Builder, and returns the Builder object; setCallback(callback: Callback): Builder. This function passes in an advertisement callback class defined in S1-1 and saves it to the Builder, and returns the Builder object. The static function setting unit is used to set the static function with and instantiate the internal class Builder through the static function with; A tool class creation unit, used to create the advertising tool class based on the callback class Callback, the internal class Builder and the static function with; The advertisement publishing unit comprises: A function setting unit, used to set the advertisement display function to public abstract void show(Activity activity); The status monitoring unit is used to call the setFullScreenContentCallback function of the advertisement object to set the advertisement display callback to monitor the advertisement display status; The parameter display unit is used to display advertisements using parameter activities.
7. A computer device, characterized in that: The invention comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the AdMob-based advertising publishing method as claimed in any one of claims 1 to 5 when executing the computer program.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the AdMob-based advertising publishing method according to any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Advertisement display method of novel aggregation advertisement system
CN113643062A
Method for realizing Android aggregation advertisement SDK (Software Development Kit)
CN114489836A