UC browser plug-in development

Source: Internet
Author: User

PIP install

What is the UC browser plug-in?


Is the UC plug-in panel. UC enables developers to develop plug-ins through open browser plug-in APIs.

Plugin type:

1: extension. Is the button shown in. In fact, it is actually a button, which triggers an event by clicking.

2: Cycler: triggers events by listening to various browser events.


Plug-in definition:

First, let's take a look at the directory structure of my current project:


After an android project is created, only the four parts need to be configured. First, add the following code to the configuration file androidmanifest. xml of the android project:

<service android:name="com.uc.addon.sdk.remote.AddonService"><intent-filter><action android:name="com.uc.browser.action.Addon"/></intent-filter></service>

In this way, the plug-in can be recognized by the browser.


Then we develop extension and explorer respectively. (Sometimes only one of them is enough as needed)


The first is extension. Your extension class must inherit the abstractextension class and override oninvoke () method.

public class NewTabDemo extends AbstractExtension {    ...    @Override    public void onInvoke(){   }     ..    }

The content in oninvoke is the operation triggered after you click the extension.

Then there is the opposite of the aggreger. The aggreger must inherit the abstractreceiver class and override the onevent method:

public class MyEventReceiver extends AbstractEventReceiver{...@Overridepublic void onEvent(int eventId , EventBase event){if (eventId == EventIds.EVENT_PAGE_START) {        ...                }                }        }

Yes, the onevent method is the operation to be triggered. Note that onevent has two parameters, which are passed in by the browser. Eventid is the event type.

The above referers listen to page loading events, so they first judge in onevent:

If (eventid = eventids. event_page_start )..

The specific event ID is provided at the end of this article.


After customizing your extension and Cycler, You need to configure addon_config.xml in the specified directory (refer to my directory structure. Below is the complete XML:

<?xml version="1.0" encoding="utf-8"?><addon name="NewTab"    icon="addon/icon.png"    versionCode="1"    minSdkVersion="2.0">                <uses-permission name="addon.permission.TAB" />    <extension name="com.example.newtest.NewTabDemo"        description="New Tab"        location="AddonBar"        icon="addon/icon.png">    </extension>        <uses-permission name="addon.permission.DIALOG" />    <uses-permission name="addon.permission.TOAST" />    <uses-permission name="addon.permission.PAGE" />    <event-receiver name="com.example.newtest.MyEventReceiver"            description="PageEventReceiver"            icon="icon.png">        <intent-filter>            <action name="addon.action.PAGE_EVENT"/>            <category name="addon.category.PAGE_START"/>            <data scheme="http" host="*"  />        </intent-filter>    </event-receiver>                     </addon>

Note the <uses-Permission> label. The permissions required by the plug-in are required. The permission table is provided at the end of this article.


In addition, because custom plug-ins are easily identified by browsers as insecure and deleted in seconds, use versions earlier than 9.5.


UC + Open Platform:

Http://plus.uc.cn/document/plugin/doc1.html#U7efcU8ff0

Here you can find the API documentation and simple development instructions.


Guide for UC browser plug-in Development: (permission description included)

Http://download.csdn.net/detail/ltianchao/7786353



 

Zookeeper
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.