#include <binder/Parcel.h>
#include "IExample.h"
using namespace android;
namespace example {
enum
{
GET_INDEX,
};
class BpExample: public BpInterface<IExample>
{
public:
BpExample(const sp<IBinder>& impl)
: BpInterface<IExample>(impl)
{
}
virtual int getIndex()
{
Parcel data, reply;
data.writeInterfaceToken(IExample::getInterfaceDescriptor());
remote()->transact(GET_INDEX, data, &reply);
return reply.readInt32();
}
};
IMPLEMENT_META_INTERFACE(Example, "android.Example");
//-----------------------------------------------------------------------
status_t BnExample::onTransact(
uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
switch(code)
{
case GET_INDEX:
{
CHECK_INTERFACE(IExample, data, reply);
reply->writeInt32(this->getIndex());
return NO_ERROR;
}
break;
default:
return BBinder::onTransact(code, data, reply, flags);
}
}
//------------------------------------------------------------------------
};
android binder 简单实例
4星 · 超过85%的资源 需积分: 13 161 浏览量
2012-07-23
15:12:06
上传
评论
收藏 2KB GZ 举报
zhaodezhong
- 粉丝: 3
- 资源: 12