Upload
skumartarget
View
103
Download
0
Embed Size (px)
Citation preview
INTENTS
CONFIDENTIAL INFORMATIONThis document is confidential and proprietary information of Target Soft Systems. Confidential Information includes, but is not limited to, the following: Corporate, Employee and Infrastructure Information about Target Soft Systems.
Target Soft Systems implementation , Training methodology, cost, project management and quality processes. Any disclosure of Confidential Information to, or use of it by a third party (i.e., a party other than authorised , will be damaging to Target Soft Systems). Ownership of all Confidential Information, no matter in what media it resides, remains with Target Soft Systems( TSS ). Confidential Information in this document shall not be disclosed outside the buyer’s proposal evaluators and shall not be duplicated, used, or disclosed – in whole or in part – for any purpose other than to evaluate this proposal without specific written permission of an authorized representative of Target Soft Systems.
Three of the core components of an Android application -
activities, services, and broadcast receivers - are activated
through messages, called intents
One activity starts another activity by creating/sending an
Intent
Types of Intents
Implicit intents
Do not name a target (the component name field is blank).
Implicit intents are often used to activate components in other
applications.
Syntax for Implicit Intent:// Implicit Intent by specifying a URI Intent i = new Intent(android.content.Intent.ACTION_VIEW,
uri.parse("http://www.example.com"));// Starts Implicit Activity startActivity(i);
Explicit intents
Designate the target component by its class (the component
name field is set by the class name)
Syntax for Explicit Intent:
// Explicit Intent by specifying its class name Intent i = new Intent(Currentactivity.this, TargetActivity.class);
i.putExtra("Key1", "ABC");
i.putExtra("Key2", "123");
// Starts TargetActivity
startActivity(i);
Value Passing using IntentWe can pass the values by using Intent and Bundle.Value passing by intent:
We can pass values from activity to another activity using Intent.Syntax:
Intent i = new (context, destination.class);// we can put the values using “putExtra” method
i.putExtra(“key1”,”Target”);startActivity(i);
//We can get the value in other activity using below syntaxgetIntent().getCharSequenceExtra (“key1”).toString();
Value passing by Bundle:We can also pass values from activity to another
activity using Bundle.
Syntax:Intent i = new (context, destination.class);Bundle b = new Bundle();b.putCharSequence(“key1”,”android”);i.putExtra(b);startActivity(i);
//We can get the value in other activity using below syntax getIntent().getExtra().getCharSequenceExtra(“key1”).toString();
Alert Dialog
• An AlertDialog is an extension of the Dialog class.
• It should be used for dialogs that use any of the following features:– A title– A text message– One, two, or three buttons– A list of selectable items (with optional checkboxes or radio
buttons)• To create an AlertDialog, use the AlertDialog.Builder subclass. • Get a Builder with AlertDialog.Builder(Context) and then use the
class's public methods to define all of the AlertDialog properties.• After you're done with the Builder, retrieve the AlertDialog object
with create().
View Groups
A ViewGroup provided a layout in which the order and appearance of
the views are placed.
A view derives from the base class android.view.ViewGroup.
Android supports the following ViewGroups,
LinearLayout RelativeLayout
AbsoluteLayout TableLayout
FrameLayout ScrollView
Linear LayoutArranges views in a single column
or single row.
Absolute LayoutEnables to specify the exact location of its
children.
Table Layout
Groups views into rows and columns.
Relative Layout
Enables us to specify how child views are positioned relative to each other.
MENU CONCEPTS WITH XML ATTRIBUTE
• Types of application menus:
Options Menu
The options menu is the primary collection of menu
items for an activity. It's where you should place actions that
have a global impact on the app, such as "Search," "Compose
email," and "Settings.“
Context Menu
A floating list of menu items that appears when
the user touches and holds a view that's registered to provide a
context menu.
Menus in Android
Plus
Home
Pre
Next
<option menu>
Sub1
Sub2
Hi
Hola
Hello
<sub-menu>
<context menu from EditText>
Long press in EditText
Submenu
A floating list of menu items that appears
when the user touches a menu item that contains a
nested menu.
ANDROID ANDROID
COMPONENTSCOMPONENTS
ActivityActivity
ServicesServices
BroadcastBroadcast
ReceiverReceiver
ContentContent
ProviderProvider
Activities
Visual user interface focused on a single thing a user can do
Services
`No visual interface – they run in the background
Broadcast Receivers
Receive and react to broadcast announcements
Content Providers Allow data exchange between applications
Service Life Cycle
ServicesNormally Services are two types, they are
1.Synchronous Service
2.Asynchronous Service
Synchronous Service:Service is an application component
representing either an application desire to perform a long-running operations while not interacting with the user or to supply functionality for other application to use.
In synchronous service we are using mainly 6 methods.
1. OnCreate()2. OnStartCommand()3. OnBind()4. OnUnbind()5. OnRebind()6. OnDestroy()
Example:
Public void onCreate(){
// TODO Auto-generated method stubsuper.onCreate();
}
@Override public int onStartCommand(Intent intent, int flags, int startId) {
// TODO Auto-generated method stub
return super.onStartCommand(intent, flags, startId);
}
@Overridepublic void onDestroy() {
super.onDestroy();
}
Asynchronous Service:AsyncTask is a abstract class provided by android
which helps us to use the UI thread proparly.
This class allows us to perform long/background operations and show its result on the UI thread without having to manipulate thread.
In Asynchronous service we are using 4 Steps.
1. OnPreExecute() 2. OnDoInBackground() 3. OnProgressUpdate() 4. OnPostExecute()
In AsyncTask we are using only 2 methods, they are1. OnCreate()2.OnStartCommand()Example:protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);
tv = (TextView)findViewById(R.id.textView1Sampleayntask);
new SampleTask().execute();}
private class SampleTask extends AsyncTask<Void, Integer, Void>{ @Override protected void onPreExecute() { tv.setText("******** Countdown Starts ********"); }
@Overrideprotected Void doInBackground(Void... params){
return null;}protected void onProgressUpdate(Integer... values)
{tv.setText( Integer.toString(values[0].intValue()));
} @Override protected void onPostExecute(Void result) {
tv.setText("******** DONE ********");
}}
THANK YOU