Android Client and PHP server communication (quad)-Aurora push Sample Engineering analysis

Source: Internet
Author: User
Android client communication with PHP server (iv)---Aurora Push example Engineering analysis

Overview

The previous section describes a method for registering an Aurora push and using its example, which prepares the framework for the sample project and prepares it for porting.

Analysis example Routines Code

First analysis of the source structure of the routine, it is recommended to follow Jpush Official document (http://docs.jpush.io/) analysis, I do so.

After registering the app, download the sample project structure as follows,



Exampleapplication.java: The class has customized an application class for the application, because calling the Jpush SDK requires invoking the Init () function API provided by Jpush, as described in the official documentation "Init You only need to invoke the API once at application startup, so you can customize a application class, which may cause multiple calls to init () if you call Init () in mainactivity. Of course, the defined Exampleapplication class needs to be configured in the Andoridmanifest.xml.

Exampleutil.java: As the name implies, "Util" means a number of global methods or properties that define static functions in this class, such as obtaining IME code, acquiring Appkey, and so on.

Mainactivity.java: This all knows, is the application of the main interface.

Myreceiver.java: This inherits the Broadcastreceiver, which is a custom sink inheriting class. If you do not define this class, the user clicks the push notification by default to jump to the main interface and cannot receive custom messages. This class needs to be configured in Andoridmanifest.xml, as well.



Pushsetactivity.java: This class mainly makes "advanced options" settings for Jpush, such as setting tag and alias, and customizing the notification bar style.

Settingactivity.java: This class is also set up for Jpush, mainly to set the receive push time.

Testactivity.java: This class inherits activity, which is mainly used to show the push message received by the user, and when the user clicks the push message in the notification bar, it jumps to the activity.


The following analysis of Andoridmanifest.xml, for the content of the complete


2 row: Specify the Android namespace

3 rows: Specifies the standard app package name, which is also the default name for an application. The package name here may be confused by someone comparing it to the Com.example.jpushdemo package under the SRC folder. Actually specializing in developing android than I know, a src can contain multiple custom packages, This Com.example.jpush package just contains some calls to the Jpush, and if you are familiar with Jpush in the future, you can completely extract the jpush operation and encapsulate it in a custom package.

4 Line: Device application version ID, must be an integer value, representing how many times the app has been updated, we can customize when we change to ourselves.

5 line: For the user to view the version, need to have some readability.

Line 7: Specify the version of the SDK you want to use in your application, such as the minimum version, the highest version, and the target version.

8-10 rows: Customize user permissions. Note that the android:name= "Com.lygk.lovelife.permission.JPUSH_MESSAGE", if your operation Jpush the package name is Com.test.jpushdemo, then this is Android : Name= "Com.test.jpushdemo.JPUSH_MESSAGE", in fact, this is not right, just a name, as long as the other reference to this permission to use the name and this consistent, such as 13 lines on the declaration of the custom permission.

13-33 rows: Declarations of the permissions required by the application, which can be found in the official documentation.

34-139 rows: The application's configuration root element, which contains all the elements related to the application configuration.

35 Rows: App icon

36 Rows: App Name

Line 37: This is the name of the Applicatioin class that we define ourselves, that is, the application launches the Exampleapplication under the Com.example.jpushdemo package.

40-47 rows: Activity active component (i.e. Interface Controller component) declaration, corresponding to Mainactivity.java. Note that every activity in an Android app must be declared in the Andoridmanifest.xml configuration file, or the activity will not be recognized or executed by the system.

49 Rows: Activity component declaration, corresponding Pushsetactivity.java

51 Rows: Activity component declaration, corresponding Settingactivity.java

53-58 rows: Activity component declaration, corresponding Testactivity.java

62-71 rows: Activity component declaration, corresponding to the Pushactivity.java defined in the Jpush SDK package, I fully suspect that this is the activity that appears in the notification bar when a push message is received by the phone.

73-77 Line: The claim label for the service component that defines and describes a specific Android service. Where Android:name represents the service service class name, android:enabled represents the services switch, and android:exported indicates whether the service can be invoked or interacted with by other application components.

81-92 Line: The Jpush SDK package defines the declaration of the Pushservice service.

95-113 Line: Boardcast receiver Broadcast receiver component declaration, used to define and describe a specific Android broadcast receiver. The android:name represents the Boardcast receiver receiver class name, and android:enabled represents the receiver switch. Note the declarations that are used for the intent message filter. must contain elements that describe the name of the specific message, and the label is used to represent the category that can handle the message component, which is the category that the action conforms to.

115 Line: Boardcast receiver Broadcast receiver component Declaration, here is alarmreceiver.

119-132 Line: Boardcast receiver Broadcast receiver component Declaration, here is the Myreceiver custom broadcast receiver, corresponding to the source code package Myreceiver.java.

136 Rows: label Jpush_channel Declaration, used to store predefined data, and similar, can also be placed in,, and These four element tags. Meta data is typically in the form of a key-value pair, with no limit on the number of data that will be placed in a bundle object, and we can use Activityinfo, ServiceInfo even read from the metadata property of the ApplicationInfo object.

137 Line: label Jpush_appkey Declaration, this is the appkey you assign when you create an app on the Aurora Push website, as shown in the Red Line box.



End

The framework of the sample code that was automatically generated when the app was created on the Aurora's Web site was analyzed, and after this analysis, I generally knew how to migrate to my application, and the next section I was going to modify the porting to my demo program.

/****************************************************************************************************

* Original articles, reproduced please specify the website: http://blog.csdn.net/mybelief321/article/details/45458863

* Luyang High Tech Studio

* Website: www.bigbearking.com

* Business Cooperation qq:1519190237

* Business Scope: Website construction, desktop software development, Android\ios development, image and film post-processing, PCB design

****************************************************************************************************/
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.