A method and device for compatibility of fragment information of different versions

CN112241287BActive Publication Date: 2025-01-17SHANG HAI CHEN LIAN KE JI YOU XIAN GONG SI
2 Cites 0 Cited by

Patent Information

Application Number
CN202011014375.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-09-24
Publication Date
2025-01-17
Estimated Expiration
2040-09-24

AI Technical Summary

Technical Problem

Different Fragment API versions in Android 3.0 cannot be used at the same time, resulting in compatibility issues when displaying different versions of Fragment in the same Activity at the same time.

Method used

By creating Fragment bridge information inherited from the first Fragment information, holding a reference to the second Fragment information, and rewriting the life cycle method and creating a view method in the bridge information, calling the corresponding second Fragment object method, and building a host callback Object to ensure the life cycle of the second Fragment object is executed correctly, thus achieving compatibility between two different versions of Fragment.

Benefits of technology

Allows the use of different versions of the Fragment API in the same Activity simultaneously, achieving perfect integration and compatibility of Fragment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112241287B_ABST
    Figure CN112241287B_ABST
Patent Text Reader

Abstract

The purpose of the present application is to provide a method and device for being compatible with different versions of fragment information. The present application bridges the life cycle of the second fragment information to the life cycle of the fragment bridging information inherited from the first fragment information. Through the bridging life cycle, the current application can appear to be calling the API of the first fragment information, which is the parent class of the fragment bridging information, but in fact is calling the API of the second fragment information. By constructing a host callback object (HostCallbacks), it is ensured that each life cycle of the second fragment object can be executed correctly, so that the second fragment object can be normally displayed on the current page through bridging, so that the two versions of the Fragment API can be used on the current page at the same time, so that two different versions of fragments can be displayed together in the same Activity, so as to be compatible with the two different versions of fragments and make the two different versions of fragments perfectly integrated.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of communications, and in particular to a technology for compatibility of fragmented information of different versions. Background Art

[0002] Android 3.0 added a new API Fragment to accommodate large-screen tablets. Later, in order to use fragments on phones below 3.0, a set of support v4 fragment APIs was provided. However, these two different versions of fragment APIs cannot be used at the same time because they are two management systems. Summary of the invention

[0003] One object of the present application is to provide a method and device for being compatible with different versions of fragment information.

[0004] According to one aspect of the present application, a method for compatibility of fragment information of different versions is provided, the method comprising:

[0005] Creating fragment bridge information inherited from the first fragment information, wherein the fragment bridge information holds a reference to a second fragment object corresponding to the second fragment information, and the first fragment information and the second fragment information correspond to different versions;

[0006] In the fragment bridging information, according to the context object corresponding to the page for displaying the fragment bridging information, a host callback object corresponding to the host callback information corresponding to the second fragment information is created, and the host callback object is assigned to the host callback variable in the second fragment object;

[0007] Rewrite at least one first method in the fragment bridging information, and call a second method corresponding to the first method in the second fragment object in each of the at least one first method;

[0008] Rewrite the first view creation method in the fragment bridging information, call the second view creation method corresponding to the first view creation method in the second fragment object in the first view creation method, assign the second view returned by the second view creation method to the view variable in the second fragment object, and use the second view as the return value of the first view creation method.

[0009] According to one aspect of the present application, a user equipment for being compatible with different versions of fragment information is provided, the device comprising:

[0010] A module, used for creating fragment bridge information inherited from the first fragment information, wherein the fragment bridge information holds a reference to a second fragment object corresponding to the second fragment information, and the first fragment information and the second fragment information correspond to different versions;

[0011] A module 12 is used to create a host callback object corresponding to the host callback information corresponding to the second fragment information according to the context object corresponding to the page used to display the fragment bridge information in the fragment bridge information, and assign the host callback object to the host callback variable in the second fragment object;

[0012] a third module, configured to rewrite at least one first method in the fragment bridging information, and call, in each of the at least one first method, a second method in the second fragment object corresponding to the first method;

[0013] A four-module is used to rewrite the first create view method in the fragment bridging information, call the second create view method corresponding to the first create view method in the second fragment object in the first create view method, assign the second view returned by the second create view method to the view variable in the second fragment object, and use the second view as the return value of the first create view method.

[0014] According to one aspect of the present application, a device for being compatible with fragment information of different versions is provided, wherein the device includes:

[0015] Processor; and

[0016] A memory arranged to store computer executable instructions which, when executed, cause the processor to perform the following operations:

[0017] Creating fragment bridge information inherited from the first fragment information, wherein the fragment bridge information holds a reference to a second fragment object corresponding to the second fragment information, and the first fragment information and the second fragment information correspond to different versions;

[0018] In the fragment bridging information, according to the context object corresponding to the page for displaying the fragment bridging information, a host callback object corresponding to the host callback information corresponding to the second fragment information is created, and the host callback object is assigned to the host callback variable in the second fragment object;

[0019] Rewrite at least one first method in the fragment bridging information, and call a second method corresponding to the first method in the second fragment object in each of the at least one first method;

[0020] Rewrite the first view creation method in the fragment bridging information, call the second view creation method corresponding to the first view creation method in the second fragment object in the first view creation method, assign the second view returned by the second view creation method to the view variable in the second fragment object, and use the second view as the return value of the first view creation method.

[0021] According to one aspect of the present application, a computer readable medium storing instructions is provided, wherein when the instructions are executed, the system performs the following operations:

[0022] Creating fragment bridge information inherited from the first fragment information, wherein the fragment bridge information holds a reference to a second fragment object corresponding to the second fragment information, and the first fragment information and the second fragment information correspond to different versions;

[0023] In the fragment bridging information, according to the context object corresponding to the page for displaying the fragment bridging information, a host callback object corresponding to the host callback information corresponding to the second fragment information is created, and the host callback object is assigned to the host callback variable in the second fragment object;

[0024] Rewrite at least one first method in the fragment bridging information, and call a second method corresponding to the first method in the second fragment object in each of the at least one first method;

[0025] Rewrite the first view creation method in the fragment bridging information, call the second view creation method corresponding to the first view creation method in the second fragment object in the first view creation method, assign the second view returned by the second view creation method to the view variable in the second fragment object, and use the second view as the return value of the first view creation method.

[0026] Compared with the prior art, the present application bridges the life cycle of the second fragment information to the life cycle of the fragment bridging information inherited from the first fragment information. Through the bridging life cycle, the current application can appear to be calling the API of the first fragment information, the parent class of the fragment bridging information, but in fact is calling the API of the second fragment information, and by constructing a host callback object (HostCallbacks), it ensures that the various life cycles of the second fragment object can be executed correctly, so that the second fragment object can be displayed normally on the current page through bridging, so that the two versions of the Fragment API can be used on the current page at the same time, so that two different versions of fragments can be displayed together in the same Activity, so as to be compatible with the two different versions of fragments, so that the two different versions of fragments can be perfectly integrated. BRIEF DESCRIPTION OF THE DRAWINGS

[0027] Other features, objects and advantages of the present application will become more apparent by reading the detailed description of non-limiting embodiments made with reference to the following drawings:

[0028] Figure 1 A flow chart of a method for compatibility of fragment information of different versions according to an embodiment of the present application is shown;

[0029] Figure 2 A structural diagram of a user equipment for being compatible with fragment information of different versions according to an embodiment of the present application is shown;

[0030] Figure 3 An exemplary system is shown that can be used to implement the various embodiments described in this application.

[0031] The same or similar reference numerals in the drawings represent the same or similar components. DETAILED DESCRIPTION

[0032] The present application is described in further detail below in conjunction with the accompanying drawings.

[0033] In a typical configuration of the present application, the terminal, the device of the service network and the trusted party all include one or more processors (eg, a central processing unit (CPU)), an input / output interface, a network interface and a memory.

[0034] Memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash memory. Memory is an example of a computer-readable medium.

[0035] Computer readable media include permanent and non-permanent, removable and non-removable media that can be used to store information by any method or technology. Information can be computer readable instructions, data structures, modules of programs or other data. Examples of computer storage media include, but are not limited to, Phase-Change Memory (PCM), Programmable Random Access Memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of random access memory (RAM), Read-Only Memory (ROM), Electrically-Erasable Programmable Read-Only Memory (EEPROM), Flash memory or other memory technology, Compact Disc Read-Only Memory (CD-ROM), Digital Versatile Disc (DVD) or other optical storage, magnetic cassettes, tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device.

[0036] The devices referred to in this application include but are not limited to user devices, network devices, or devices formed by integrating user devices and network devices through a network. The user devices include but are not limited to any mobile electronic products that can interact with users (for example, interact with users through a touchpad), such as smart phones, tablet computers, etc. The mobile electronic products can use any operating system, such as Android operating system, iOS operating system, etc. Among them, the network device includes an electronic device that can automatically perform numerical calculations and information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application specific integrated circuits (Application Specific Integrated Circuit, ASIC), programmable logic devices (Programmable Logic Device, PLD), field programmable gate arrays (Field Programmable Gate Array, FPGA), digital signal processors (Digital Signal Processor, DSP), embedded devices, etc. The network devices include but are not limited to computers, network hosts, single network servers, multiple network server sets or multiple servers. The cloud is composed of a large number of computers or network servers based on cloud computing (Cloud Computing), wherein cloud computing is a type of distributed computing, a virtual supercomputer composed of a group of loosely coupled computer sets. The network includes but is not limited to the Internet, a wide area network, a metropolitan area network, a local area network, a VPN network, a wireless self-organizing network (Ad Hoc network), etc. Preferably, the device may also be a program running on the user device, the network device, or a device formed by integrating the user device and the network device, the network device, the touch terminal, or the network device and the touch terminal through a network.

[0037] Of course, those skilled in the art should understand that the above-mentioned devices are only examples, and other existing or future devices that are applicable to the present application should also be included in the scope of protection of the present application and are included here by reference.

[0038] In the description of the present application, “plurality” means two or more, unless otherwise clearly and specifically defined.

[0039] Figure 1A flow chart of a method for compatibility of fragment information of different versions according to an embodiment of the present application is shown, the method comprising step S11, step S12, step S13 and step S14. In step S11, the user device creates fragment bridging information inherited from the first fragment information, wherein the fragment bridging information holds a reference to a second fragment object corresponding to the second fragment information, and the first fragment information and the second fragment information correspond to different versions; in step S12, the user device creates a host callback object corresponding to the host callback information corresponding to the second fragment information in the fragment bridging information according to the context object corresponding to the page used to display the fragment bridging information, and assigns the host callback object to the host callback variable in the second fragment object; in step S13, the user device rewrites at least one first method in the fragment bridging information, and calls the second method corresponding to the first method in the second fragment object in each first method of the at least one first method; in step S14, the user device rewrites the first create view method in the fragment bridging information, calls the second create view method corresponding to the first create view method in the second fragment object in the first create view method, assigns the second view returned by the second create view method to the view variable in the second fragment object, and uses the second view as the return value of the first create view method.

[0040] In step S11, the user device creates fragment bridging information inherited from the first fragment information, wherein the fragment bridging information holds a reference to a second fragment object corresponding to the second fragment information, and the first fragment information and the second fragment information correspond to different versions. In some embodiments, fragment information (e.g., Fragment class) is a UI fragment that can be embedded in a page (e.g., Activity). Fragment cannot be used alone and needs to be nested in Activity. The life cycle of Fragment is affected by the life cycle of the host Activity. In some embodiments, different versions of Fragments may exist on the user device at the same time. For example, if the operating system corresponding to the user device is Android 3.0 or above, the operating system contains a system-native version of the Fragment API (android.app.Fragment). If the operating system corresponding to the user device is Android 3.0 or below, the support v4 package can be accessed in the current application. The support v4 package contains another version of the Fragment API (android.support.v4.app.Fragment). Normally, these two versions of the Fragment API cannot be used at the same time because they are two management systems. However, sometimes we need to display the two versions of fragments together. For example, a third-party SDK is accessed in the current application. The SDK and the current application itself use different versions of the Fragment API, and they must be placed in the same Activity, but neither party can easily change the API. In some embodiments, the first fragment information is a native version of Fragment (android.app.Fragment), and the second fragment information is a v4 version of Fragment (android.support.v4.app.Fragment), or the first fragment information is a v4 version of Fragment (android.support.v4.app.Fragment), and the second fragment information is a native version of Fragment (android.app.Fragment).In some embodiments, fragment bridging information (e.g., FragmentBridge class) inherited from the first fragment information is created in the current application, and the parent class of FragmentBridge is the first fragment information. Preferably, FragmentBridge and the second fragment information are located in the same package (e.g., android.app package, or android.support.v4.app package) so that FragmentBridge can directly call protected type variables and default type variables in the second fragment information. FragmentBridge holds a reference to a second fragment object (e.g., Fragment object) corresponding to the second fragment information (e.g., a reference to the second fragment object is held through the fragmentV4 variable in FragmentBridge, this.fragmentV4=fragment). The reference to the second fragment object can be passed into FragmentBridge through a constructor with the second fragment object as an incoming parameter (e.g., FragmentBridge(Fragment fragment) constructor), or can be passed into FragmentBridge through other related methods with the second fragment object as an incoming parameter (e.g., void setFragment(Fragment fragment) method). In some embodiments, by overriding (for example, Override) multiple lifecycle callback methods (for example, onStart() method) in the first fragment information of the parent class of FragmentBridge, and calling the lifecycle-related method corresponding to the lifecycle callback method in the second fragment object held by FragmentBridge in each lifecycle callback method (for example, fragmentV4.performStart()), the lifecycle of the second fragment information can be bridged to the lifecycle of the fragment bridging information inherited from the first fragment information. By bridging the lifecycle, the current application can appear to be calling the API of the first fragment information of the parent class of the fragment bridging information, but in fact it is calling the API of the second fragment information, so that the two versions of the Fragment API can be used simultaneously on the current page, so that two different versions of fragments can be displayed together in the same Activity to be compatible with the two different versions of fragments, so that the two different versions of fragments can be perfectly integrated.

[0041] In step S12, the user device creates a host callback object corresponding to the host callback information corresponding to the second fragment information in the fragment bridge information according to the context object corresponding to the page used to display the fragment bridge information, and assigns the host callback object to the host callback variable in the second fragment object. In some embodiments, it is necessary to pass the context object (e.g., Context) corresponding to the current page used to display FragmentBridge into FragmentBridge, and the context object can be passed into FragmentBridge through a constructor whose input parameter is the context object (e.g., FragmentBridge (Context context) constructor), or can be passed into FragmentBridge through other related methods whose input parameters are the context object (e.g., void setContext (Context context) method). In some embodiments, according to the context object passed into FragmentBridge, a host callback object corresponding to the host callback information (e.g., HostCallbacks) corresponding to the second fragment information is created, for example, newHostCallbacks (getActivity (context)), wherein the getActivity (context) method is used to obtain the corresponding Activity object according to the context object, and the input parameter of the HostCall backs constructor is the Activity object. In some embodiments, the created host callback object is assigned to the host callback variable in the second fragment object (for example, the mHost variable, fragmentV4.mHost = new HostCallbacks(getActivity(context))). In this way, the second fragment object can call back the relevant methods in the host (i.e., the Activity object corresponding to the current page) through the HostCallbacks object held by the mHost variable during its various life cycles, thereby realizing the normal communication between the second fragment object and the host Activity object in the fragment bridging information inherited from the first fragment information, thereby ensuring that the various life cycles of the second fragment object can be executed correctly by constructing a host callback object (HostCallbacks), so that the second fragment object can be normally displayed on the current page through bridging.

[0042] In step S13, the user equipment rewrites at least one first method in the fragment bridging information, and calls a second method corresponding to the first method in the second fragment object in each of the at least one first method. In some embodiments, at least one first method in the first fragment information of its parent class is rewritten in FragmentBridge, and the at least one first method includes multiple life cycle callback methods of the first fragment information (for example, onAttach, onDettach, onStart, onResume, onCreate, onViewCreated, onPause, onStop, onLowMemory, onDestroyView, onDestroy, onHiddenChanged). In some embodiments, in each rewritten first method (for example, onPause), the second method corresponding to the first method in the second fragment object (for example, performPause) is called, for example, @Override public void onPause(){super.onPause(); fragmentV4.performPause();}, wherein super.onPause() calls the onPause method in the first fragment object of its parent class of FragmentBridge, fragmentV4.performPause() calls the performPause method in the second fragment object, and the onPause method corresponds to the performPause method.

[0043] In step S14, the user device rewrites the first view creation method in the fragment bridging information, calls the second view creation method corresponding to the first view creation method in the second fragment object in the first view creation method, assigns the second view returned by the second view creation method to the view variable in the second fragment object, and uses the second view as the return value of the first view creation method. In some embodiments, the first view creation method (for example, View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) method) is rewritten in the fragment bridging information, and the first view creation method is used to create a view object (View) corresponding to the fragment and provide it to the page object (Activity) used to display the fragment bridging information. In some embodiments, the second view creation method (also the onCreateView method) in the second fragment object is called in the onCreateView method of the fragment bridging information, and the View object returned by the second view creation method is assigned to the view variable in the second fragment object (for example, the mView variable, fragmentV4.mView = fragmentV4.performCreateView (inflater, container, savedInstanceState), and the View object is provided as the return value of the onCreateView method of the fragment bridging information to the Activity used to display the fragment bridging information, so that it can be displayed normally on the current page. In some embodiments, the parameter container (ViewGroup container object, used to load the view object corresponding to the fragment) passed into the first view creation method is also copied to the corresponding container variable in the second fragment object, for example, the mContainer variable, fragmentV4.mContainer = container. In some embodiments, the View object returned by the second view creation method is also assigned to the internal view variable in the second fragment object, for example, the mInnerView variable, if (fragmentV4.mView! = null) {fragmentV4.mInnerView = fragmentV4.mView;}.

[0044] In some embodiments, the method further includes: the user device creates the second fragment object; creates a fragment bridge object corresponding to the fragment bridge information, passes the second fragment object into the fragment bridge object, and adds the fragment bridge object to the page object corresponding to the current page, so as to display the second fragment object in the current page. In some embodiments, in actual use, in the Activity object corresponding to the current page to which the second fragment object needs to be added, a second fragment object corresponding to the second fragment information is created, for example, Fragment fragment = newFragment(), and then a FragmentBridge object is created, and the fragment object is passed into the FragmentBridge object, and the FragmentBridge object is added to the Activity object, so as to display the second fragment object in the current page by bridging.

[0045] In some embodiments, the passing the second fragment object into the fragment bridge object comprises: calling a third method of the fragment bridge object, wherein the third method takes the second fragment object as an input parameter. In some embodiments, a FragmentBridge object may be created first, and then the second fragment object may be passed into the FragmentBridge object by calling the third method of the FragmentBridge object taking the second fragment object as an input parameter.

[0046] In some embodiments, the creating a fragment bridge object corresponding to the fragment bridge information and passing the second fragment object into the fragment bridge object includes: creating a fragment bridge object corresponding to the fragment bridge information according to a construction method of the fragment bridge information, wherein the construction method takes the second fragment object as an input parameter. In some embodiments, the second fragment object can be passed into the FragmentBridge object while creating the FragmentBridge object by calling a construction method of FragmentBridge with the second fragment object as an input parameter.

[0047] In some embodiments, the fragment bridging information and the second fragment information are located in the same package. In some embodiments, FragmentBridge holds a reference to the second fragment object corresponding to the second fragment information. In order to facilitate FragmentBridge to directly call protected type variables and default type variables in the second fragment information, FragmentBridge and the second fragment information need to be located in the same package. In some embodiments, according to the path information corresponding to the package where the second fragment information is located (for example, "android.support.v4.app"), a package with the same path information is created in the current application, and FragmentBridge is created in the package.

[0048] In some embodiments, the method further includes: the user equipment creates a third method in the fragment bridging information, wherein the input parameter of the third method is the second fragment object. In some embodiments, in order for FragmentBridge to hold a reference to the second fragment object corresponding to the second fragment information, a third method with the second fragment object as an input parameter may be created in FragmentBridge, and by calling the third method, the second fragment object may be passed into FragmentBridge, so that FragmentBridge holds a reference to the second fragment object. For example, the third method may be void setFragment(Fragment fragment).

[0049] In some embodiments, the third method is a construction method of the fragment bridge information. In some embodiments, in order for FragmentBridge to hold a reference to the second fragment object corresponding to the second fragment information, a construction method with the second fragment object as an input parameter can be created in FragmentBridge, and the second fragment object can be passed into FragmentBridge when the FragmentBridge object is created by calling the construction method, so that FragmentBridge holds a reference to the second fragment object. For example, the construction method can be FragmentBridge(Fragment fragment).

[0050] In some embodiments, the method further includes: the user device creates a fourth method in the fragment bridging information, wherein the input parameter of the fourth method is the context object. In some embodiments, it is necessary to pass the context object (e.g., Context) corresponding to the current page used to display FragmentBridge into FragmentBridge, and a fourth method with the input parameter of the Context object can be created in FragmentBridge. By calling the fourth method, the Context object corresponding to the current page can be passed into FragmentBridge. For example, the fourth method can be void setContext (Context context). In some embodiments, a fourth method with the input parameters of the second fragment object and the Context object can also be created in FragmentBridge. By calling the fourth method, the Context object corresponding to the current page and the second fragment object can be passed into FragmentBridge. For example, the fourth method can be void set (Context context, Fragment fragment).

[0051] In some embodiments, the fourth method is a construction method for the fragment bridging information. In some embodiments, it is necessary to pass the Context object corresponding to the current page used to display FragmentBridge into FragmentBridge. A construction method with the Context object as the passed-in parameter can be created in FragmentBridge, and the Context object can be passed into FragmentBridge when the FragmentBridge object is created by calling the construction method. For example, the construction method can be FragmentBridge(Fragment fragment). For example, the construction method can be void setContext(Context context). In some embodiments, a construction method with the second fragment object and the Context object as the passed-in parameters can also be created in FragmentBridge, and the Context object and the second fragment object can be passed into FragmentBridge when the FragmentBridge object is created by calling the construction method. For example, the construction method can be FragmentBridge(Fragment fragment, Context context).

[0052] In some embodiments, the at least one first method includes multiple life cycle callback methods. In some embodiments, the multiple life cycle callback methods include but are not limited to onAttach, onDettach, onStart, onResume, onCreate, onViewCreated, onPause, onStop, onLowMemory, onDestroyView, onDestroy, onHiddenChanged and other methods.

[0053] In some embodiments, calling the second method corresponding to the first method in the second fragment object in each of the at least one first method includes: calling the first method in the first fragment information in each of the at least one first method except the view creation callback method corresponding to the first view creation method, and calling the second method corresponding to the first method in the second fragment object. In some embodiments, by overriding the at least one first method, the first method in the first fragment information of the parent class of FragmentBridge is called in each first method (for example, onStop method) except the first view creation method (for example, onCreateView method), and the second method corresponding to the first method in the second fragment object is called (for example, fragmentV4.performStop()).

[0054] In some embodiments, the creating a host callback object corresponding to the host callback information corresponding to the second fragment information according to the context object corresponding to the page for displaying the fragment bridge information includes: obtaining the page object corresponding to the context object according to the context object corresponding to the page for displaying the fragment bridge information; and creating a host callback object corresponding to the host callback information corresponding to the second fragment information according to the page object. In some embodiments, according to the Context object corresponding to the current page for displaying the FragmentBridge passed into the FragmentBridge, the Activity object corresponding to the Context object is obtained by calling the getActivity(Context context) method, and then according to the Activity object, a host callback object corresponding to the host callback information (e.g., HostCallbacks) corresponding to the second fragment information is created, for example, new HostCallbacks(getActivity(context)), wherein the parameter passed into the construction method of HostCallbacks is the Activity object.

[0055] In some embodiments, the method further includes: the user device creates host callback information corresponding to the second fragment information, wherein the host callback information inherits from the fragment host callback information corresponding to the second fragment information, and the host callback information holds a reference to the page object. In some embodiments, host callback information (e.g., HostCallbacks class) inherited from the fragment host callback information (e.g., FragmentHostCallback class) corresponding to the second fragment information is created in the current application, and the parent class of the HostCallbacks class is the FragmentHostCallback class. In some embodiments, the FragmentHostCallback class corresponds to the second fragment information, and the versions of the two are consistent, both are native versions of the API, or both are v4 versions of the API. In some embodiments, the second fragment information is a native version of Fragment (android.app.Fragment), and at this time, the FragmentHostCallback class is also a native version of FragmentHostCallback (android.app.FragmentHostCallback). In some embodiments, the second fragment information is a v4 version of Fragment (android.support.v4.app.Fragment), in which case the FragmentHostCallback class is also a v4 version of Fragment HostCallback (android.support.v4.app.FragmentHostCallback). In some embodiments, the HostCallbacks class holds a reference to the Activity object corresponding to the current page used to display the FragmentBridge (for example, the reference to the Activity object is held by the activity variable in HostCallbacks, this.activity=activity), and the reference to the Activity object can be passed to the HostCallbacks class through a constructor whose parameter is the Activity object (for example, the HostCallbacks(ActivityActivity) constructor), or can be passed to the HostCallbacks class through other related methods whose parameters are the Activity object (for example, the void setActivity(Activity activity) method).

[0056] In some embodiments, the fragment host callback information is generic information, and the generic type of the host callback information is a page object type. In some embodiments, FragmentHostCallback is a generic class, for example, <t>, HostCallbacks specifies the specific generic type as the Activity object type when inheriting FragmentHost Callback, for example, class HostCallbacks extendsFragmentHostCallback <activity>.

[0057] In some embodiments, the method further includes: the user device creates a second constructor in the host callback information, wherein the input parameter of the second constructor is the page object. In some embodiments, a constructor whose input parameter is an Activity object can be created in HostCallbacks, and the Activity object can be passed into HostCallbacks when the HostCallbacks object is created by calling the constructor, so that HostCallbacks holds a reference to the Activity object. For example, the constructor can be HostCallbacks(Activity activity), public HostCallbacks(Activity activity){this.activity=activity;}, and a reference to the Activity object is held through the activity variable in HostCallbacks.

[0058] In some embodiments, the method further includes: the user device calls the third construction method corresponding to the fragment host callback information in the second construction method, and the input parameters of the third construction method include the page object and the context object. In some embodiments, the construction method of its parent class FragmentHostCallback is called in the construction method of HostCallbacks, and the input parameters of the construction method of FragmentHostCallback include the Activity object and the Context object. Preferably, the input parameters of the construction method of FragmentHostCallback also include a handle (e.g., Handler) object and a window animation (e.g., windowAnimations) object, for example, publicHostCallbacks(Activity activity){super(activity,activity,new Handler(),0); this.activity=activity;}.

[0059] In some embodiments, the method further includes: the user device rewrites the page object callback method in the host callback information, and uses the page object as the return value of the page object callback method. In some embodiments, the page object callback method (e.g., Activity onGetHost()) in its parent class FragmentHostCallback is rewritten in HostCallbacks, and the Activity object held by HostCallbacks is used as the return value of the page object callback method.

[0060] In some embodiments, the method further includes: the user device rewrites at least one fifth method in the host callback information, calls the sixth method corresponding to the fifth method in the page object in each of the at least one fifth method, and determines the return value of the fifth method according to the return value of the sixth method. In some embodiments, at least one fifth method (for example, boolean onHasView()) in its parent class FragmentHostCallback is rewritten in HostCallbacks, and the sixth method corresponding to the fifth method in the Activity object held by HostCallbacks is called in each of the at least one fifth method, for example, activity.getWindow(), and the return value of the fifth method is determined according to the return value of the sixth method, for example, @Override public boolean onHasView(){final Window w=activity.getWindow();return(w!=null&&w.peekDecorView()!=null);}. In some embodiments, the fifth method overridden in HostCall backs includes but is not limited to onDump, onShouldSaveFragmentState, onGetLayoutInflater, onShouldShowRequestPermissionRationale, onFindViewById, onHasView, etc.

[0061] In some embodiments, determining the return value of the fifth method according to the return value of the sixth method includes: using the return value of the sixth method as the return value of the fifth method. In some embodiments, the return value of the sixth method can be directly used as the return value of the fifth method, for example, the fifth method is LayoutInflater onGetLayoutInflater(), the sixth method is activity.getLayoutInflater().cloneInContext(activity), @Override public LayoutInflater onGet LayoutInflater(){returnactivity.getLayoutInflater().cloneInContext(activity);}.

[0062] Figure 2 A structural diagram of a user device for being compatible with fragmented information of different versions according to an embodiment of the present application is shown. The device includes a one-module 11, a one-two module 12, a one-three module 13 and a one-four module 14. A first module 11 is used to create fragment bridging information inherited from the first fragment information, wherein the fragment bridging information holds a reference to a second fragment object corresponding to the second fragment information, and the first fragment information and the second fragment information correspond to different versions; a second module 12 is used to create a host callback object corresponding to the host callback information corresponding to the second fragment information in the fragment bridging information according to the context object corresponding to the page used to display the fragment bridging information, and assign the host callback object to the host callback variable in the second fragment object; a third module 13 is used to rewrite at least one first method in the fragment bridging information, and call the second method corresponding to the first method in the second fragment object in each first method of the at least one first method; a fourth module 14 is used to rewrite the first view creation method in the fragment bridging information, call the second view creation method corresponding to the first view creation method in the second fragment object in the first view creation method, and assign the second view returned by the second view creation method to the view variable in the second fragment object, and use the second view as the return value of the first view creation method.

[0063] A module 11 is used to create fragment bridge information inherited from the first fragment information, wherein the fragment bridge information holds a reference to a second fragment object corresponding to the second fragment information, and the first fragment information and the second fragment information correspond to different versions. In some embodiments, the fragment information (e.g., the Fragment class) is a UI fragment that can be embedded in a page (e.g., an Activity). The Fragment cannot be used alone and needs to be nested in an Activity. The life cycle of the Fragment is affected by the life cycle of the host Activity. In some embodiments, different versions of Fragments may exist on the user device at the same time. For example, if the operating system corresponding to the user device is Android 3.0 or above, the operating system contains a system-native version of the Fragment API (android.app.Fragment). If the operating system corresponding to the user device is Android 3.0 or below, the support v4 package can be accessed in the current application. The support v4 package contains another version of the Fragment API (android.support.v4.app.Fragment). Normally, these two versions of the Fragment API cannot be used at the same time because they are two management systems. However, sometimes we need to display the two versions of fragments together. For example, a third-party SDK is accessed in the current application. The SDK and the current application itself use different versions of the Fragment API, and they must be placed in the same Activity, but neither party can easily change the API. In some embodiments, the first fragment information is a native version of Fragment (android.app.Fragment), and the second fragment information is a v4 version of Fragment (android.support.v4.app.Fragment), or the first fragment information is a v4 version of Fragment (android.support.v4.app.Fragment), and the second fragment information is a native version of Fragment (android.app.Fragment).In some embodiments, fragment bridging information (e.g., FragmentBridge class) inherited from the first fragment information is created in the current application, and the parent class of FragmentBridge is the first fragment information. Preferably, FragmentBridge and the second fragment information are located in the same package (e.g., android.app package, or android.support.v4.app package) so that FragmentBridge can directly call protected type variables and default type variables in the second fragment information. FragmentBridge holds a reference to a second fragment object (e.g., Fragment object) corresponding to the second fragment information (e.g., a reference to the second fragment object is held through the fragmentV4 variable in FragmentBridge, this.fragmentV4=fragment). The reference to the second fragment object can be passed into FragmentBridge through a constructor with the second fragment object as an incoming parameter (e.g., FragmentBridge(Fragment fragment) constructor), or can be passed into FragmentBridge through other related methods with the second fragment object as an incoming parameter (e.g., void setFr agment(Fragment fragment) method). In some embodiments, by overriding (for example, Override) multiple lifecycle callback methods (for example, onStart() method) in the first fragment information of the parent class of FragmentBridge, and calling the lifecycle-related method corresponding to the lifecycle callback method in the second fragment object held by FragmentBridge in each lifecycle callback method (for example, fragmentV4.performStart()), the lifecycle of the second fragment information can be bridged to the lifecycle of the fragment bridging information inherited from the first fragment information. By bridging the lifecycle, the current application can appear to be calling the API of the first fragment information of the parent class of the fragment bridging information, but in fact it is calling the API of the second fragment information, so that the two versions of the Fragment API can be used simultaneously on the current page, so that two different versions of fragments can be displayed together in the same Activity to be compatible with the two different versions of fragments, so that the two different versions of fragments can be perfectly integrated.

[0064] The first and second modules 12 are used to create a host callback object corresponding to the host callback information corresponding to the second fragment information in the fragment bridge information according to the context object corresponding to the page used to display the fragment bridge information, and assign the host callback object to the host callback variable in the second fragment object. In some embodiments, it is necessary to pass the context object (e.g., Context) corresponding to the current page used to display FragmentBridge into FragmentBridge. The context object can be passed into FragmentBridge through a constructor whose input parameter is the context object (e.g., FragmentBridge (Context context) constructor), or can be passed into FragmentBridge through other related methods whose input parameters are the context object (e.g., void setContext (Context context) method). In some embodiments, according to the context object passed into FragmentBridge, a host callback object corresponding to the host callback information (e.g., HostCallbacks) corresponding to the second fragment information is created, for example, newHostCallbacks (getActivity (context)), wherein the getActivity (context) method is used to obtain the corresponding Activity object according to the context object, and the input parameter of the HostCallbacks constructor is the Activity object. In some embodiments, the created host callback object is assigned to the host callback variable in the second fragment object (for example, the mHost variable, fragmentV4.mHost = new HostCallbacks(getActivity(context))). In this way, the second fragment object can call back the relevant methods in the host (i.e., the Activity object corresponding to the current page) through the HostCallbacks object held by the mHost variable during its various life cycles, thereby realizing the normal communication between the second fragment object and the host Activity object in the fragment bridging information inherited from the first fragment information, thereby ensuring that the various life cycles of the second fragment object can be executed correctly by constructing a host callback object (HostCallbacks), so that the second fragment object can be normally displayed on the current page through bridging.

[0065] A third module 13 is used to rewrite at least one first method in the fragment bridging information, and call a second method corresponding to the first method in the second fragment object in each first method of the at least one first method. In some embodiments, at least one first method in the first fragment information of its parent class is rewritten in FragmentBridge, and the at least one first method includes multiple life cycle callback methods of the first fragment information (for example, onAttach, onDettach, onStart, onResume, onCreate, onViewCreated, onPause, onStop, onLowMemory, onDestroyView, onDestroy, onHiddenChanged). In some embodiments, in each rewritten first method (for example, onPause), the second method corresponding to the first method in the second fragment object (for example, performPause) is called, for example, @Override public void onPause(){super.onPause(); fragmentV4.performPause();}, wherein super.onPause() calls the onPause method in the first fragment object of its parent class of FragmentBridge, fragmentV4.performPause() calls the performPause method in the second fragment object, and the onPause method corresponds to the performPause method.

[0066] A module 14 is used to rewrite the first view creation method in the fragment bridging information, call the second view creation method corresponding to the first view creation method in the second fragment object in the first view creation method, assign the second view returned by the second view creation method to the view variable in the second fragment object, and use the second view as the return value of the first view creation method. In some embodiments, the first view creation method (for example, View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) method) is rewritten in the fragment bridging information, and the first view creation method is used to create a view object (View) corresponding to the fragment and provide it to the page object (Activity) used to display the fragment bridging information. In some embodiments, the second view creation method (also the onCreateView method) in the second fragment object is called in the onCreateView method of the fragment bridging information, and the View object returned by the second view creation method is assigned to the view variable in the second fragment object (for example, the mView variable, fragmentV4.mView = fragmentV4.performCreateView (inflater, container, savedInstanceState), and the View object is provided as the return value of the onCreateView method of the fragment bridging information to the Activity used to display the fragment bridging information, so that it can be displayed normally on the current page. In some embodiments, the parameter container (ViewGroup container object, used to load the view object corresponding to the fragment) passed into the first view creation method is also copied to the corresponding container variable in the second fragment object, for example, the mContainer variable, fragmentV4.mContainer = container. In some embodiments, the View object returned by the second view creation method is also assigned to the internal view variable in the second fragment object, for example, the mInnerView variable, if (fragmentV4.mView! = null) {fragmentV4.mInnerView = fragmentV4.mView;}.

[0067] In some embodiments, the device is further configured to: create the second fragment object; create a fragment bridge object corresponding to the fragment bridge information, pass the second fragment object into the fragment bridge object, and add the fragment bridge object to the page object corresponding to the current page, so as to display the second fragment object in the current page. Figure 1 The embodiments shown are the same or similar, so they are not described again and are incorporated herein by reference.

[0068] In some embodiments, the step of passing the second fragment object into the fragment bridge object comprises: calling a third method of the fragment bridge object, wherein the third method takes the second fragment object as an input parameter. Figure 1 The embodiments shown are the same or similar, so they are not described again and are incorporated herein by reference.

[0069] In some embodiments, the creating a fragment bridge object corresponding to the fragment bridge information and passing the second fragment object into the fragment bridge object includes: creating a fragment bridge object corresponding to the fragment bridge information according to a construction method of the fragment bridge information, wherein the input parameter of the construction method is the second fragment object. Figure 1 The embodiments shown are the same or similar, so they are not described again and are incorporated herein by reference.

[0070] In some embodiments, the fragment bridging information and the second fragment information are located in the same packet. Figure 1 The embodiments shown are the same or similar, so they are not described again and are incorporated herein by reference.

[0071] In some embodiments, the device is further configured to: create a third method in the fragment bridging information, wherein an input parameter of the third method is the second fragment object. Figure 1 The embodiments shown are the same or similar, so they are not described again and are incorporated herein by reference.

[0072] In some embodiments, the third method is a method for constructing the fragment bridging information. Figure 1 The embodiments shown are the same or similar, so they are not described again and are incorporated herein by reference.

[0073] In some embodiments, the device is further configured to: create a fourth method in the fragment bridging information, wherein an input parameter of the fourth method is the context object. Figure 1 The embodiments shown are the same or similar, so they are not described again and are incorporated herein by reference.

[0074] In some embodiments, the fourth method is a method for constructing the fragment bridging information. Figure 1 The embodiments shown are the same or similar, so they are not described again and are incorporated herein by reference.

[0075] In some embodiments, the at least one first method includes multiple lifecycle callback methods. Figure 1 The embodiments shown are the same or similar, so they are not described again and are incorporated herein by reference.

[0076] In some embodiments, calling the second method corresponding to the first method in the second fragment object in each of the at least one first method includes: calling the first method in the first fragment information in each of the at least one first method except the view creation callback method corresponding to the first view creation method, and calling the second method corresponding to the first method in the second fragment object. Figure 1 The embodiments shown are the same or similar, so they are not described again and are incorporated herein by reference.

[0077] In some embodiments, the creating a host callback object corresponding to the host callback information corresponding to the second fragment information according to the context object corresponding to the page for displaying the fragment bridge information includes: obtaining a page object corresponding to the context object according to the context object corresponding to the page for displaying the fragment bridge information; and creating a host callback object corresponding to the host callback information corresponding to the second fragment information according to the page object. Figure 1 The embodiments shown are the same or similar, so they are not described again and are incorporated herein by reference.

[0078] In some embodiments, the device is further used to: create host callback information corresponding to the second fragment information, wherein the host callback information inherits the fragment host callback information corresponding to the second fragment information, and the host callback information holds a reference to the page object. Figure 1 The embodiments shown are the same or similar, so they are not described again and are incorporated herein by reference.

[0079] In some embodiments, the fragment host callback information is generic information, and the generic type of the host callback information is a page object type. Figure 1 The embodiments shown are the same or similar, so they are not described again and are incorporated herein by reference.

[0080] In some embodiments, the device is further configured to: create a second construction method in the host callback information, wherein the input parameter of the second construction method is the page object. Figure 1 The embodiments shown are the same or similar, so they are not described again and are incorporated herein by reference.

[0081] In some embodiments, the device is further configured to: in the second construction method, call a corresponding third construction method in the fragment host callback information, and the input parameters of the third construction method include the page object and the context object. Figure 1 The embodiments shown are the same or similar, so they are not described again and are incorporated herein by reference.

[0082] In some embodiments, the device is further configured to: rewrite the page object callback method in the host callback information, and use the page object as the return value of the page object callback method. Figure 1 The embodiments shown are the same or similar, so they are not described again and are incorporated herein by reference.

[0083] In some embodiments, the device is further configured to: rewrite at least one fifth method in the host callback information, call a sixth method corresponding to the fifth method in the page object in each of the at least one fifth method, and determine a return value of the fifth method according to a return value of the sixth method. Figure 1 The embodiments shown are the same or similar, so they are not described again and are incorporated herein by reference.

[0084] In some embodiments, determining the return value of the fifth method according to the return value of the sixth method includes: using the return value of the sixth method as the return value of the fifth method. Figure 1 The embodiments shown are the same or similar, so they are not described again and are incorporated herein by reference.

[0085] Figure 3 An exemplary system is shown that can be used to implement the various embodiments described in this application.

[0086] like Figure 3 In some embodiments shown, the system 300 can be used as any of the devices in the various described embodiments. In some embodiments, the system 300 may include one or more computer-readable media (e.g., system memory or NVM / storage device 320) with instructions and one or more processors (e.g., (one or more) processors 305) coupled to the one or more computer-readable media and configured to execute instructions to implement modules to perform the actions described in this application.

[0087] For one embodiment, system control module 310 may include any suitable interface controller to provide any suitable interface to at least one of processor(s) 305 and / or any suitable device or component in communication with system control module 310 .

[0088] The system control module 310 may include a memory controller module 330 to provide an interface to the system memory 315. The memory controller module 330 may be a hardware module, a software module, and / or a firmware module.

[0089] The system memory 315 may be used, for example, to load and store data and / or instructions for the system 300. For one embodiment, the system memory 315 may include any suitable volatile memory, such as a suitable DRAM. In some embodiments, the system memory 315 may include double data rate type four synchronous dynamic random access memory (DDR4 SDRAM).

[0090] For one embodiment, system control module 310 may include one or more input / output (I / O) controllers to provide interfaces to NVM / storage device 320 and communication interface(s) 325 .

[0091] For example, NVM / storage device 320 may be used to store data and / or instructions. NVM / storage device 320 may include any suitable non-volatile memory (e.g., flash memory) and / or may include any suitable non-volatile storage device(s) (e.g., one or more hard disk drives (HDDs), one or more compact disk (CD) drives, and / or one or more digital versatile disk (DVD) drives).

[0092] NVM / storage device 320 may include storage resources that are physically part of the device on which system 300 is installed, or it may be accessible to the device without being part of the device. For example, NVM / storage device 320 may be accessed over a network via communication interface(s) 325.

[0093] Communication interface(s) 325 may provide an interface for system 300 to communicate over one or more networks and / or with any other suitable devices. System 300 may wirelessly communicate with one or more components of a wireless network in accordance with any of one or more wireless network standards and / or protocols.

[0094] For one embodiment, at least one of the processor(s) 305 may be packaged together with the logic of one or more controllers of the system control module 310 (e.g., the memory controller module 330). For one embodiment, at least one of the processor(s) 305 may be packaged together with the logic of one or more controllers of the system control module 310 to form a system-in-package (SiP). For one embodiment, at least one of the processor(s) 305 may be integrated on the same die with the logic of one or more controllers of the system control module 310. For one embodiment, at least one of the processor(s) 305 may be integrated on the same die with the logic of one or more controllers of the system control module 310 to form a system on chip (SoC).

[0095] In various embodiments, the system 300 may be, but is not limited to: a server, a workstation, a desktop computing device, or a mobile computing device (e.g., a laptop computing device, a handheld computing device, a tablet computer, a netbook, etc.). In various embodiments, the system 300 may have more or fewer components and / or a different architecture. For example, in some embodiments, the system 300 includes one or more cameras, a keyboard, a liquid crystal display (LCD) screen (including a touch screen display), a non-volatile memory port, multiple antennas, a graphics chip, an application specific integrated circuit (ASIC), and a speaker.

[0096] The present application also provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer code. When the computer code is executed, the method described in any of the preceding items is executed.

[0097] The present application also provides a computer program product. When the computer program product is executed by a computer device, the method described in any of the preceding items is executed.

[0098] The present application also provides a computer device, the computer device comprising:

[0099] one or more processors;

[0100] a memory for storing one or more computer programs;

[0101] When the one or more computer programs are executed by the one or more processors, the one or more processors are caused to implement the method as described in any of the preceding items.

[0102] It should be noted that the present application can be implemented in software and / or a combination of software and hardware, for example, can be implemented using an application specific integrated circuit (ASIC), a general purpose computer or any other similar hardware device. In one embodiment, the software program of the present application can be executed by a processor to implement the steps or functions described above. Similarly, the software program of the present application (including relevant data structures) can be stored in a computer-readable recording medium, for example, a RAM memory, a magnetic or optical drive or a floppy disk and similar devices. In addition, some steps or functions of the present application can be implemented using hardware, for example, as a circuit that cooperates with a processor to perform each step or function.

[0103] In addition, a part of the present application may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present application through the operation of the computer. Those skilled in the art should understand that the existence of computer program instructions in computer-readable media includes but is not limited to source files, executable files, installation package files, etc., and accordingly, the way in which computer program instructions are executed by a computer includes but is not limited to: the computer directly executes the instruction, or the computer compiles the instruction and then executes the corresponding compiled program, or the computer reads and executes the instruction, or the computer reads and installs the instruction and then executes the corresponding installed program. Here, the computer-readable medium can be any available computer-readable storage medium or communication medium accessible to the computer.

[0104] Communication media include media by which communication signals containing, for example, computer readable instructions, data structures, program modules or other data are transmitted from one system to another. Communication media may include guided transmission media such as cables and wires (e.g., fiber optic, coaxial, etc.) and wireless (unguided transmission) media that can propagate energy waves, such as acoustic, electromagnetic, RF, microwave and infrared. Computer readable instructions, data structures, program modules or other data may be embodied as a modulated data signal in, for example, a wireless medium such as a carrier wave or similar mechanism such as embodied as part of spread spectrum technology. The term "modulated data signal" refers to a signal whose one or more characteristics are changed or set in such a manner as to encode information in the signal. Modulation may be analog, digital, or a hybrid modulation technique.

[0105] By way of example and not limitation, computer-readable storage media may include volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storage of information such as computer-readable instructions, data structures, program modules or other data. For example, computer-readable storage media include, but are not limited to, volatile memory, such as random access memory (RAM, DRAM, SRAM); and non-volatile memory, such as flash memory, various read-only memories (ROM, PROM, EPROM, EEPROM), magnetic and ferromagnetic / ferroelectric memories (MRAM, FeRAM); and magnetic and optical storage devices (hard disks, magnetic tapes, CDs, DVDs); or other media now known or later developed that can store computer-readable information / data for use by a computer system.

[0106] Here, according to an embodiment of the present application, a device is included, which includes a memory for storing computer program instructions and a processor for executing the program instructions, wherein, when the computer program instructions are executed by the processor, the device is triggered to run the methods and / or technical solutions based on the aforementioned multiple embodiments of the present application.

[0107] It is obvious to those skilled in the art that the present application is not limited to the details of the above exemplary embodiments, and that the present application can be implemented in other specific forms without departing from the spirit or basic features of the present application. Therefore, from any point of view, the embodiments should be regarded as exemplary and non-restrictive, and the scope of the present application is limited by the attached claims rather than the above description, so it is intended to include all changes that fall within the meaning and scope of the equivalent elements of the claims in the present application. Any figure mark in the claims should not be regarded as limiting the claims involved. In addition, it is obvious that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or devices stated in the device claim can also be implemented by one unit or device through software or hardware. The words first, second, etc. are used to indicate names, and do not indicate any particular order.< / activity> < / t>

Claims

1. A method for compatibility of fragment information of different versions, wherein: The method comprises: Creating fragment bridge information inherited from the first fragment information, wherein the fragment bridge information holds a reference to a second fragment object corresponding to the second fragment information, and the first fragment information and the second fragment information correspond to different versions; In the fragment bridging information, according to the context object corresponding to the page for displaying the fragment bridging information, a host callback object corresponding to the host callback information corresponding to the second fragment information is created, and the host callback object is assigned to the host callback variable in the second fragment object; Rewrite at least one first method in the fragment bridging information, call the first method in the first fragment information in each first method except the view creation callback method corresponding to the first view creation method in the at least one first method, and call the second method corresponding to the first method in the second fragment object, wherein the at least one first method includes multiple life cycle callback methods of the first fragment information; Rewrite the first view creation method in the fragment bridging information, call the second view creation method corresponding to the first view creation method in the second fragment object in the first view creation method, assign the second view returned by the second view creation method to the view variable in the second fragment object, and use the second view as the return value of the first view creation method.

2. The method according to claim 1, wherein: The fragment bridging information and the second fragment information are located in the same packet.

3. The method according to claim 1, wherein: The method further comprises: A third method is created in the fragment bridging information, wherein an input parameter of the third method is the second fragment object.

4. The method according to claim 3, wherein: The third method is a method for constructing the fragment bridging information.

5. The method according to claim 1, wherein: The method further comprises: A fourth method is created in the fragment bridging information, wherein an input parameter of the fourth method is the context object.

6. The method according to claim 5, wherein: The fourth method is a method for constructing the fragment bridging information.

7. The method according to claim 1, wherein: The step of creating a host callback object corresponding to the host callback information corresponding to the second fragment information according to the context object corresponding to the page for displaying the fragment bridging information includes: According to the context object corresponding to the page for displaying the fragment bridging information, obtaining the page object corresponding to the context object; A host callback object corresponding to the host callback information corresponding to the second fragment information is created according to the page object.

8. The method according to claim 7, wherein: The method further comprises: Host callback information corresponding to the second fragment information is created, wherein the host callback information inherits from the fragment host callback information corresponding to the second fragment information, and the host callback information holds a reference to the page object.

9. The method according to claim 8, wherein: The method further comprises: A second construction method is created in the host callback information, wherein an input parameter of the second construction method is the page object.

10. The method according to claim 9, wherein: The method further comprises: In the second construction method, a corresponding third construction method in the fragment host callback information is called, and the input parameters of the third construction method include the page object and the context object.

11. The method according to claim 8, wherein: The method further comprises: The page object callback method is rewritten in the host callback information, and the page object is used as the return value of the page object callback method.

12. The method according to claim 8, wherein: The method further comprises: At least one fifth method is rewritten in the host callback information, a sixth method corresponding to the fifth method in the page object is called in each of the at least one fifth method, and a return value of the fifth method is determined according to a return value of the sixth method.

13. The method according to claim 12, wherein: Determining the return value of the fifth method according to the return value of the sixth method includes: The return value of the sixth method is used as the return value of the fifth method.

14. The method according to claim 1, wherein: The method further comprises: Creating the second fragment object; Create a fragment bridge object corresponding to the fragment bridge information, pass the second fragment object into the fragment bridge object, and add the fragment bridge object to the page object corresponding to the current page to display the second fragment object in the current page.

15. The method according to claim 14, wherein the step of transferring the second fragment object into the fragment bridge object comprises: A third method of the fragment bridge object is called, wherein an input parameter of the third method is the second fragment object.

16. The method according to claim 14, wherein: The creating a fragment bridge object corresponding to the fragment bridge information and transferring the second fragment object into the fragment bridge object includes: According to the construction method of the fragment bridging information, a fragment bridging object corresponding to the fragment bridging information is created, wherein the input parameter of the construction method is the second fragment object.

17. A device for compatibility with different versions of fragmented information, characterized in that: The device comprises: Processor; and A memory arranged to store computer executable instructions which, when executed, cause the processor to perform a method as claimed in any one of claims 1 to 16.

18. A computer readable medium storing instructions which, when executed, cause a system to perform the operations of the method of any one of claims 1 to 16.

Citation Information

Patent Citations

  • Universal method for monitoring Android foreground and Android background

    CN108153646A

  • A method and apparatus for activating a component

    CN109408133A