Chapter 2 MC Part 3
Chapter 2 MC Part 3
Mulugeta G.
1
Introduction to Intents
• An Intent is a simple message object that is used to
communicate between android components such as
activities, content providers, broadcast receivers
and services.
• Intents are also used to transfer data between
activities.
• Intents are used generally for starting a new activity
using startActivity().
2
Intent
3
Use of Intent
4
Types of Intent in Android
5
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.
6
• 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”
7
Intent select = new Intent(Intent.ACTION_CAMERA);
send.setData(uri);
startActivity(Intent.createChooser(
select,”Select an Image from Camera”));
8
9
Launching Activities and Sub Activities
10
11
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.
12
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 −
13
• 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/");
14
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.
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.
21
Packaging an Application(Deployment)
22
Installing Application on Android Device
23
Publishing on the Android Market
25
Tips: Android Color
26
Tips: Android Color
27
Tips: Android Color
28
Thank You
?
29