LoadUrl. The only unusual bit with this edition of is that we invoke on the widget, to tell it to load a Web page (in this case
The only unusual bit with this edition of is that we invoke on the widget, to tell it to load a Web page (in this case, the home page of some random firm).
However, we also have to make one change to , requesting permission to access the Internet:
If we fail to add this permission, the browser will refuse to load pages.
The resulting activity looks like a Web browser, just with hidden scrollbars (see Figure 13‑1).
Figure 13‑1. The Browser1 sample application
As with the regular Android browser, you can pan around the page by dragging it, while the directional pad moves you around all the focusable elements on the page.
What is missing is all the extra accouterments that make up a Web browser, such as a navigational toolbar.
Now, you may be tempted to replace the URL in that source code with something else, such as Google’s home page or another page that relies upon Javascript. By default Javascript is turned off in widgets. If you want to enable Javascript, call on the instance.
Дата добавления: 2015-05-16; просмотров: 711;