Address 4: Installed programs

Comp194 ma l.jpg
1 / 13
1065 days ago, 341 views
PowerPoint PPT Presentation
Utilize an Intent to make Android dispatch its own framework program. ... For instance: naturally WebView will open connections in another Android program window. ...

Presentation Transcript

Slide 1

´╗┐Comp194-MA Lecture 4: Embedded programs

Slide 2

Motivation There are a few reasons why an application might need to have entry to a web program. Illustration: show HTML parts, get to outer administrations, open Google look ect. Also, getting to HTTP assets without a web program reflection layer is repetitive and pointless.

Slide 3

Android's answer Android gives two answers for this issue: Use an Intent to make Android dispatch its own particular framework program. Implant a WebView controller inside an Activity Both of these methodologies have their own interesting favorable circumstances and weaknesses.

Slide 4

Android goals The Android expectations are a reflection that permit exercises to effortlessly dispatch different exercises. The stage ships with twelve or so default goals. They permit things like propelling a phone call, seeing a contact, and obviously opening the web program.

Slide 5

Intents aces/cons Launching a plan to handle perusing uses the implicit Android program which is more hearty than WebView . The implicit program accompanies "assistants" like a status bar, stacking bar, ect . The real con is that the application looses control of the telephone when the program is propelled. There is no real way to catch occasions or compel the client once again into an application.

Slide 6

Using WebView The WebView controller takes into account HTML parts and pages to be shown in a movement. WebView interfaces with an Android movement like whatever other gadget. In that capacity, an action can catch occasions and additionally associate with the DOM on the page. Tragically, the WebView execution does not bolster AJAX out of the crate.

Slide 7

Intent Code Intent i = new Intent(); i.setAction("android.intent.action.VIEW"); i.addCategory("android.intent.category.BROWSABLE"); uri = Uri.parse(fbClient.getLoginURL(authToken)); i.setData(uri);/set the URL you need to open here fb.startActivity(i);/fire the occasion/Your action will keep running while the program is open. /The client can come back to your action on the off chance that they hit "back" on the telephone's hard catches.

Slide 8

WebView Code Embed in a layout.xml document: <WebView android:id="@+id/webview" android:layout_width="fill_parent" android:layout_height="0dip" android:layout_weight="1"/> To explore to a page: WebView wv = (WebView) fb.findViewById( webview); wv.loadUrl(fbClient.getLoginURL(authToken)); wv.setWebViewClient(new WebViewClient(){ @Override open boolean shouldOverrideUrlLoading(WebView see, String url) { return false; }});

Slide 9

WebView gotcha's WebView has a ton of unintuitive default conduct. For instance: as a matter of course WebView will open connections in another Android program window. To supersede this, pass the WebView controller a WebViewClient with the right capacities abrogated.

Slide 10

WebView case In the case code: open boolean shouldOverrideUrlLoading (WebView see, String url) { return false; } Overriding shouldOverrideUrlLoading and returning false will make WebView stack joins.

Slide 11

Misc. With the goal for WebView to get to the web your application needs the android.permission.INTERNET consent. Arrange dormancy can be reproduced utilizing the DDMS reassure. You most likely need to set WebView to fill_parent since little programs are unpleasant. As of SDK 1.1 R1 WebView loads HTTP over SSL URLs especially gradually.

Slide 12

Google docs

Slide 13

The Project This is a major one so we'll break it into two weeks. Objective: Use the Facebook API to stack the photographs for the contacts in the telephone. Issues: How to interface with Facebook? How to make a contact? How to download photographs? (???)