在线
客服
在线
QQ
电话
咨询
400-700-1020
购买 公众号 返回
顶部

Loding the player....

本视频来由慧都网提供   查看原视频>>

MyEclipse移动Web模拟器指南

1. Preview Apps in the iOS and Android Simulator

The Mobile Web Simulator can be used for both previewing an app during development, and for browsing the web to view apps or sites on the Internet. Using the simulator, you can view apps on different devices, change the orientation, test device movement, such as shaking or rotating, test geolocation changes, and test the effects of various stages of battery life.

Note: Accelerometer, geolocation, battery life, and platform event tests require the use of PhoneGap APIs in your app.

The Mobile Web Simulator is based on the Chrome browser using the same WebKit rendering engine as iOS and Android. The simulator emulates the Cordova 2.0 API and supports previews for iPhone, iPad, Nexus S, Kindle Fire 7″, and Samsung Tab 10.1 devices.

2. Launching the Web Simulator

To open a project application for testing, right-click the project in the Explorer, and select PhoneGap>Preview Application in Mobile Web Simulator.

MyEclipse 移动模拟器
Opening a project in the simulator
To open the Mobile Web Simulator for viewing apps or sites on the Internet, do the following:
  1. Click MyEclipse 移动模拟器, or select Mobile>Mobile Web Simulator.
    MyEclipse 移动模拟器
    Opening the simulator to view web content
  2. Enter a URL into the address bar to view web content.

3. Setting Simulator Configuration

Project applications can be run and tested in the simulator. In addition, you can use the simulator to browse the Internet and run mobile applications from the web.

Using the Mobile Web Simulator preferences, you can set a home page that appears in the device when you open the Mobile Web Simulator from the toolbar icon MyEclipse 移动模拟器.

MyEclipse 移动模拟器
Home page preference

Note: The Mobile Web Simulator preference page also allows you to enter the path to your Google Chrome installation. If you receive an error that Chrome cannot be found when you try to open the simulator, open the preference page and set the path to the Chrome browser.

3.1 Setting the Device & OS Version

The Mobile Web Simulator supports simulation for iPhone, iPad and multiple Android devices. You can change the device view to see how apps appear on any supported device, as well as in either landscape or portrait orientation.

With the simulator open, click MyEclipse 移动模拟器, select the device you want to view from the Device drop-down, and click Done. You can also set a custom size by entering custom height and width dimensions.

MyEclipse 移动模拟器
Selecting the device view

Change the operating system version by opening the System Summary panel and selecting a version from the OS drop-down list.

MyEclipse 移动模拟器
Changing the OS version

Scaling

You can set the scaling of the device in the simulator window. Open the Orientation and Zooming panel, and drag the slider to select a scaling percentage. Select the Fit to Screen checkbox to fit the device in the window.

MyEclipse 移动模拟器
Setting scaling

Rotating

When designing an application, you want to consider the screen orientations of the device. If you are designing an application to run in both portrait and landscape, you want to test both orientations.

To rotate the device screen in the simulator, open the Orientation and Zooming panel, and click the orientation you want to view.

MyEclipse 移动模拟器
Landscape orientation

4. Emulating Cordova APIs

The PhoneGap Build Service creates a hybrid app from your mobile project using the PhoneGap runtime and API. This runtime includes the JavaScript cordova.js API and is available to your iOS and Android applications. Visit the Apache Cordova project for project information and API documentation.

4.1  Testing Using the Accelerometer

The accelerometer measures device movement speed, which allows detection of the device’s orientation, roll, pitch and yaw. A Shake button allows you to test how shaking the device affects your app. Simulating movement with the accelerometer provides information to apps that use the Accelerometer API.

  1. Open the Accelerometer panel.
  2. Drag the 3D device image to change the degree of rotation. Hold down the Shift key to adjust the alpha axis rotation. If your app uses the Accelerometer API to respond to various device movements, you can preview the effects of those movements.
    MyEclipse 移动模拟器
    Changing degree of axis rotation
  3. Click Shake to simulate shaking the device.

4.2  Testing Battery Power Changes

By simulating various battery power states, you can test the effects on your app. Test the results when the device is plugged in, with a low battery, or test at various battery level percentages. Simulating battery power provides information to apps that use the battery-related events of Events API.

  1. Open the Power Manger panel. The following simulations apply if your app uses the Events API to respond to various stages of battery life.
  2. Select the Plugged In checkbox to simulate having the device plugged into a power source. This simulates charging time, which gradually increases battery power.
    MyEclipse 移动模拟器
    Battery charging simulation
  3. Test various battery levels by changing the battery level percentage.
    MyEclipse 移动模拟器
    Setting battery level percentage
  4. Click Simulate low battery to set a starting percentage and a speed at which the battery level goes to 0.
    MyEclipse 移动模拟器
    Configuring low battery simulation

4.3 Testing Geolocation Changes

The Geolocation panel allows you to test changes to the physical location of the device, including moving along a route. Running a route simulation provides geolocation information to apps that use the Geolocation API.

  1. Open the Geolocation panel.
  2. Use the map to find a location you want to mark or enter coordinates for a location.
  3. Click Marker, and click the point on the map you want to mark. To create a route, mark various points on the route and double-click the map to complete the route.
    MyEclipse 移动模拟器
    Mapping a geolocation route
  4. Click Play to draw the route. If your app uses the Geolocation API to respond to geolocation information, you can preview the effects of location changes.
    MyEclipse 移动模拟器
    Route simulation

4.4  Testing Platform Events

By firing simulating platform events, you can test the effects on apps that use the Events API.

  1. Open the Platform Events panel.
  2. Select an event you want to test, and click Fire Event.
    MyEclipse 移动模拟器
    Platform event simulation

5. Auto-Reloading Simulator with File Changes

During development, you can hot sync your app changes with the simulator so you can leave the simulator open and test as you code. To automatically sync with the simulator, click MyEclipse 移动模拟器 on the MyEclipse toolbar.

MyEclipse 移动模拟器
Auto-reload toggle for hot-sync’ing changes

6. Debugging & Inspecting Apps

The Mobile Web Simulator leverages the Chrome Developer Tools for debugging and inspecting your apps. Simply right-click the screen displayed in the device emulator, and select Inspect element to invoke the developer tools.

Learn more about the Chrome Developer Tools:

Guide – https://developers.google.com/chrome-developer-tools/

Videos – https://developers.google.com/chrome-developer-tools/docs/videos