) throws android.os.RemoteException;
}
Package com.amuro.entity;
Import Android.os.Parcel;
Import android.os.Parcelable;
public class Person implements parcelable {private int id;
private String name;
Public person () {} public person (int ID, String name) {this.id = ID;
THIS.name = name;
} public int getId () {return id;
} public void setId (int id) {this.id = ID;
} public String GetName () {return name;
} public void SetName (String name) {this.name = na
and Division operations.ServiceTestB is a common process that provides addition and subtraction operations for two integers.TestService is a program for testing processes. It mainly verifies the interface functions of two service processes. The code canPut it in any process for access and call
A. Compile the Service Process
ServiceTestA. h header file definition:
# Ifndef _ SERVICE_TEST_A __# Define _ SERVICE_TEST_A __
# Include # Include # Include # Include
Namespace android {// Inherit the B
the methods and parameters, see StringUtils Api Guide.
10. ParcelUtils
Android Parcel tool class, which can be used to read or write special types of data from parcel, for example:ReadBoolean (Parcel in) reads boolean data from pacelReadHashMap (Parcel in, ClassLoader loader) reads map-type data from pacelWriteBoolean
I. Basic points of knowledge1. Transfer data between activity1) Pass basic type or stringIntent.putextra ("username", username);Getintent ();Intent.getstringextra ("username");2) transmission in the form of bundlesBundle bundle = new bundle (); Bundle.putstring ("username", username);Bundle.putstring ("password", password);Intent.putextras (bundle);Bundle bundle = Intent.getextras ();String username = bundle.getstring ("username");String Password = bundle.getstring ("password");3) Passing Custom
implement an Parcelable interface, for Android serialization objects.The implementation of the serializable interface is javase itself support, and parcelable is the unique features of Android, efficiency than the implementation of serializable interface high,It can also be used in interprocess communication (IPC). Implementation of the Serializable interface is very simple, declare it.The implementation of the Parcelable interface is slightly more complex, but more efficient, and it is recomme
category in C ++. The complete program code is:
Addservice. h file:
# Ifndef android_guilh_add_service_h
# Define android_guilh_add_service_h
# Include
# Include
# Include
# Include
Namespace android
{
Class addservice: Public bbinder
{
Mutable mutex mlock;
Int32_t mnextconnid;
Public:
Static int instantiate ();
Addservice ();
Virtual ~ Addservice ();
Virtual status_t ontransact (uint32_t, const parcel , par
principle knowledge.In binder IPC communication, binder is the communication medium, and parcel is the communication content. During the method remote call, the parameters are packaged into parcel format for transmission. The ibinder object is no exception. Let's take a look at writestrongbinder () in the parcel class (because the Java layer and native Layer Met
public int delta (long rawcontactid) of rawcontactid whose ID is long rawcontactid on the entityset. Public valuesdelta getsuperprimaryentry (final string mimetype) searches for the valuesdelta whose mime is mimetype in the collection. If there is issuperprimary () valuesdelta, it is directly returned; otherwise, the first isprimary () is returned () valuesdelta. If no isprimary () valuesdelta exists, the first valuesdelta is returned. Public int describecontents () returns 0. // nothing specia
() {// TODO Auto-generated method stubreturn 0;}@Overridepublic void writeToParcel(Parcel parcel, int arg1) {// TODO Auto-generated method stubparcel.writeString(strName);parcel.writeInt(iAge);}public static final Parcelable.Creator
CREATOR = new Creator
() {public People createFromParcel(Parcel source) {People pTemp = new People("",0);pTemp.strName =
AIDL (2): Transmission of complex objects, aidl transmission of ObjectsIPC transmits complex objects through AIDL
1. Define data transmission objects
Person. aidl file:
In the Person. java file:
(1) Implement the parcelable Interface
(2) provide a static final attribute named CREATOR
Package com. liujun. aidl;
Import android. OS. Parcel;
Import android. OS. Parcelable;
Public class Person implements Parcelable {
Private String name;
Private in
Code list of reasons for parcel detention(1) Code of the reason for receiving and sharing0. Other reasons1. Incorrect customer address2. The address is unknown and the phone number is fax or no answer is received3. The address is unknown and the phone number does not match the address4. This contact is not found at the customer address.5. The guard will not allow access to the customer6. The customer is off duty7. The customer has left/gone out8. Chan
include to make our test apk.include $(call all-makefiles-under,$(LOCAL_PATH))
$ VI Res/layout/Main. xml
Delete the Android: text line in
Or add tests: local_module_tags: = optional tests to Android. mk.
$ VI src/COM/example/MyApp/myservicetestactivity. Java
Package COM. example. myApp; import android. app. activity; import android. OS. bundle; import android. OS. ibinder; import android. OS. parcel; import android. OS. servicemanager; import andr
parameters of the Fileutils Api Guide can be seen.8, ResourceutilsThe Android Resource tool class can be used to read content from the raw and assets directories of the Android resource directory, such as:Gefilefromassets (context context, String fileName) Gets the contents of a file in the assets directoryGefilefromraw (context context, int resId) Gets the contents of a file in the raw directorySource visible Resourceutils.java, more methods and more detailed parameters of the Resourceutils Ap
proxy class will be created (as mentioned below). ③asbinder (): This method is used to return the current object itself.④ontransact (int code,parcel data,parcel reply,int Flags): This method is typically executed in the binder thread pool on the server side. That is, the remote request will be processed in this method. The code value passed is used to infer the client's request target, either Addperson or
IMediaPlayerClient.h is used to describe an interface for a MediaPlayer client, as described below:
Class Imediaplayerclient:public IInterface{PublicDeclare_meta_interface (mediaplayerclient);virtual void Notify (int msg, int ext1, int ext2) = 0;};
Class Bnmediaplayerclient:public Bninterface { Public: Virtual status_t ontransact (uint32_t code, const parcel data, parcel* reply, uint32_t
article. We will analyze the following. First of all, to introduce the original rational knowledge.Binder IPC Communication, Binder is the medium of communication, parcel is the content of communication. method during a remote invocation, its parameters are packaged in parcel form to be passed. IBinder objects are no exception, let's take a look at the Writestrongbinder () in the
the invocation occurs within the process, and the same effect is done with the help of the IPC during the process. The data sent through Transact () is Parcel,parcel is a general buffer, with the exception of data with some metadata that describes its contents. Metadata is used to manage references to ibinder objects so that they can be saved when a buffer is moved from one process to another. This ensures
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.