android icc part ii
Download
Skip this Video
Download Presentation
Android ICC Part II

Loading in 2 Seconds...

play fullscreen
1 / 16

Android ICC Part II - PowerPoint PPT Presentation


  • 135 Views
  • Uploaded on

Android ICC Part II. Inter-component communication. Broadcast Receivers. BRs are app components that receive intents sent from the system and/or other apps A BR has to register with the Activity Manager and Package Manager Registration can be done through the The manifest file

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' Android ICC Part II' - ince


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
android icc part ii

Android ICC Part II

Inter-component communication

broadcast receivers
Broadcast Receivers
  • BRs are app components that receive intents sent from the system and/or other apps
  • A BR has to register with the Activity Manager and Package Manager
  • Registration can be done through the
    • The manifest file
    • Programmatically
br registration within manifest
BR registration within Manifest

<receiver android:name=\'\'MsgListener\'\' >

<intent-filter>

<action android:name=\'\'pacman.intent.action.BROADCAST\'\' />

</intent-filter>

</receiver>

br registration within manifest1
BR registration within Manifest

<receiver android:name=\'\'MsgListener\'\' >

<intent-filter>

<action android:name=\'\'pacman.intent.action.BROADCAST\'\' />

</intent-filter>

</receiver>

Class responsible for processing the Intent

Filter to specify what intents to receive

br program registration
BR program. registration

IntentFilter filter = new IntentFilter();

filter.addAction(``pacman.intent.action.BROADCAST’’);

receiver = new BroadcastReceiver() f

//@Override public void onReceive(Context context, Intent intent)

{

System.out.println(``message receivednn\'\');

}

};

registerReceiver(receiver, filter);

br program registration1
BR program. registration

Filter to specify what intents to receive

IntentFilter filter = new IntentFilter();

filter.addAction(``pacman.intent.action.BROADCAST’’);

receiver = new BroadcastReceiver() f

//@Override public void onReceive(Context context, Intent intent)

{

System.out.println(``message receivednn\'\');

}

};

registerReceiver(receiver, filter);

Action performed when the intent is received

Registration of the BR and filter

registering broadcast receivers
Registering Broadcast Receivers
  • When BRs are registered programmatically generate REGISTER_RECEIVER_TRANSACTION ioctl to AM via Binder
  • Registration through manifest does not generate any transactions
broadcasting intents
Broadcasting Intents
  • To broadcast an intent the sendBroadcast API should be used
  • Generates a BROADCAST_INTENT_TRANSACTION ioctl to AM through the Binder

Intent intent = new Intent(``pacman.intent.action.BROADCAST\'\');

intent.putExtra(``message\'\',\'\'Wake up.\'\');

sendBroadcast(intent);

content providers
Content Providers
  • CPs are the components in an app responsible for storing data
  • CPs must be declared in the manifest file using the <provider> tag
  • CPs are accessed by URI:
    • content://<authority>/<resource>
content providers1
Content Providers
  • Access to a CP is handled by the AM
  • Ioctlwith GET_CONTENT_PROVIDER_TRANSACTION
    • Specifying the authority
  • The AM finds the suitable CP and sends back a handler to communicate directly with the CP
  • Then the app can send URI along with the requested operations:
    • QUERY_T, GET_TYPE_T, INSERT_T, DELETE_T, UPDATE_T, BULK_INSERT_T, OPEN_FILE_T, OPEN_ASSET_FILE_T
service manager
Service Manager
  • The Service Manager is a special system service to keep track of the services available in a device
  • An app that wants to provider a service to others can publish its service through the SM
  • Communication to SM is done through Binder
service manager commands
Service Manager Commands
  • The SM accepts the following commands:
    • publish: takes two arguments – service name and address. This is used for publishing a service within the SM
    • get/check: take one argument – service name. The SM returns a address of the service in the form of a handler
    • list: this lists the service names registered with the SM
service manager ioctl
Service Manager ioctl

ioctl on /dev/binder with BINDER_WRITE_READ

cmd:BC_TRANSACTION:

target name = android.os.IServiceManager

code = SVC_MGR_GET_SERVICE

service name = isms

final thoughts
Final Thoughts
  • Android ICC is both very powerful and flexible
  • High-level API for dynamic interaction between apps
    • Discovery of functionality on the fly
  • If not protected properly it can lead to serious consequences
ad