Chapter 3
Chapter 3
1
Introduction to Intents
2
Use of Intent
3
Types of Intent in Android
• Two types of Intent:
– Implicit Intent
– Explicit Intent
1. Implicit Intent
• specifies an action that can invoke any app on the
device to be able to perform an action.
• is useful when your app cannot perform the action
but other apps probably can and you’d like the
user to pick which app to use.
4
2. Explicit Intent
• is an Intent where you explicitly define the
component that needs to be called by the Android
System.
• is one that you can use to launch a specific app
component, such as a particular activity or service
in your app.
5
• The Different Methods Used in Intent
– Action_Main: Adds an action to an intent Filter.
– Action_Pick: It is using for picking the image from CAMERA or
GALLERY
– Action_Chooser: It is used for choosing the image from the gallery
– Action_Dial: Display the phone dialer with the given number filled
in.
– Action_Call: Placing and immediate phone call
– Action_Send: Sending Text content from one activity to other.
– Action_SendTo: Preparing an SMS. The text is supplied as an Extra
element. The intent excepts such as values to be called “sms_body”
6
Intent select = new Intent(Intent.ACTION_CAMERA);
send.setData(uri);
startActivity(Intent.createChooser(
select,”Select an Image from Camera”));
7
8
Launching Activities and Sub Activities
9
10
Sr.No Callback & Description
onCreate()
1
This is the first callback and called when the activity is first created.
onStart()
2
This callback is called when the activity becomes visible to the user.
onResume()
3
This is called when the user starts interacting with the application.
onPause()
The paused activity does not receive user input and cannot execute any
4
code and called when the current activity is being paused and the
previous activity is being resumed.
onStop()
5
This callback is called when the activity is no longer visible.
onDestroy()
6
This callback is called before the activity is destroyed by the system.
onRestart()
7
This callback is called when the activity restarts after stopping it. 11
WebView
• WebView is a view that display web pages inside
your application.
• In order to add WebView to your application, you
have to add <WebView>element to your xml
layout file. Its syntax is as follows −
12
• In order to use it, you have to get a reference of
this view in Java file.
• To get a reference, create an object of the class
WebView. Its syntax is:
WebView browser = (WebView) findViewById(R.id.webview);
• In order to load a web url into the WebView, you
need to call a method loadUrl(String url) of the
WebView class, specifying the required url.
• Its syntax is:
browser.loadUrl("http://www.ebc.et/");
13
Sr.No Method & Description
1 canGoBack()
This method specifies the WebView has a back history item.
2 canGoForward()
This method specifies the WebView has a forward history item.
3 clearHistory()
This method will clear the WebView forward and backward history.
4 destroy(): This method destroy the internal state of WebView.
5 findAllAsync(String find)
This method find all instances of string and highlight them.
6 getProgress(): This method gets the progress of the current page.
20
Packaging an Application(Deployment)
21
Installing Application on Android Device
22
Publishing on the Android Market
• Publishing is the general process that makes your
Android applications available to users.
• When you publish an Android application you
perform two main tasks:
1. You prepare the application for release.
– During the preparation step you build a release version of
your application, which users can download and install on
their Android-powered devices.
2. You release the application to users.
– During the release step you publicize, sell, and distribute the
release version of your application to users.
• For more information visit:
– https://developer.android.com/studio/publish/ 23