Android RoboGuice2 Usage Guide (1) overview

Source: Internet
Author: User
Tags bind class definition

Roboguice recently launched the 2.0 version. Compared with 1.1, it has:

Improve the stability

Support Fragment

More concise and easy to use

However, because RoboGuice2 is not fully backward compatible with RoboGuice1.1, the project that originally developed using RobuGuice1.1 needs to make some modifications to the code to use RoboGuice2.0.

Here are some of the upgrade considerations for upgrading to RoboGuice2.0 using the Eclipse IDE development environment:

1. Download the new Roboguice Library, the Roboguice2.0 library consists of four libraries, as shown in the following illustration:

Libraries can be downloaded from the http://code.google.com/p/roboguice/.

2. The roboapplication in the original 1.1 did not exist in 2.0. 2.0 more convenient to use, the usual application if there is not a custom binding, you do not need to derive application.

3. If you use a custom module to define bindings, in 2.0 you can define it through XML, such as the res/values/roboguice.xml definition

<?xml version= "1.0″encoding=" utf-8″?>

<resources>

<string-array name= "Roboguice_modules" >

<item>com.pstreets.guice.demo.greetingmodule</item >

</string-array> </resources>

4. Classes originally derived from abstractandroidmodule were changed to Abstractmodule in 2.0, such as:

Ublic class Greetingmodule extends Abstractmodule {

@Override protected void Configure () {bind (Igreetingservice.class). to (Helloworld.class);//bind ( Igreetingservice.class). to (Hellochina.class); }

}

5. Modify the Androidmanifest.xml, remove the original defined Roboapplication derived class definition, and remove the Roboapplication derived class definition from the code.

These are the main steps to upgrade from RoboGuice1.1 to 2.0. Before learning 2.0, you can refer to the 1.1 introduction, the basic concept is still the same.

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.