本文整理汇总了Java中android.os.IBinder.transact方法的典型用法代码示例。如果您正苦于以下问题:Java IBinder.transact方法的具体用法?Java IBinder.transact怎么用?Java IBinder.transact使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.os.IBinder
的用法示例。
在下文中一共展示了IBinder.transact方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onServiceConnected
import android.os.IBinder; //导入方法依赖的package包/类
@Override
public void onServiceConnected(ComponentName className, IBinder service) {
//Get the OpenUDID from the remote service
try {
//Send a random number to the service
android.os.Parcel data = android.os.Parcel.obtain();
data.writeInt(mRandom.nextInt());
android.os.Parcel reply = android.os.Parcel.obtain();
service.transact(1, android.os.Parcel.obtain(), reply, 0);
if (data.readInt() == reply.readInt()) //Check if the service returns us this number
{
final String _openUDID = reply.readString();
if (_openUDID != null) { //if valid OpenUDID, save it
if (LOG) Log.d(TAG, "Received " + _openUDID);
if (mReceivedOpenUDIDs.containsKey(_openUDID)) mReceivedOpenUDIDs.put(_openUDID, mReceivedOpenUDIDs.get(_openUDID) + 1);
else mReceivedOpenUDIDs.put(_openUDID, 1);
}
}
} catch (RemoteException e) {if (LOG) Log.e(TAG, "RemoteException: " + e.getMessage());}
mContext.unbindService(this);
startService(); //Try the next one
}
示例2: getAdvertisingID
import android.os.IBinder; //导入方法依赖的package包/类
public String getAdvertisingID() {
try {
Intent intent = new Intent("com.google.android.gms.ads.identifier.service.START");
intent.setPackage("com.google.android.gms");
Object gSConnection = new GSConnection();
this.context.bindService(intent, gSConnection, 1);
IBinder takeBinder = gSConnection.takeBinder();
Parcel obtain = Parcel.obtain();
Parcel obtain2 = Parcel.obtain();
obtain.writeInterfaceToken("com.google.android.gms.ads.identifier.internal" +
".IAdvertisingIdService");
takeBinder.transact(1, obtain, obtain2, 0);
obtain2.readException();
String readString = obtain2.readString();
obtain2.recycle();
obtain.recycle();
Ln.i("getAdvertisingID === %s", readString);
return readString;
} catch (Throwable th) {
Ln.w(th);
return null;
}
}
示例3: activeClientGetService
import android.os.IBinder; //导入方法依赖的package包/类
private void activeClientGetService() {
if(isReady()){
for (Iterator<Map.Entry<String,IBinder>> iter = mClientServiceManagerContainer.entrySet().iterator();iter.hasNext();) {
Map.Entry<String,IBinder> me = iter.next();
IBinder clientServiceManager = me.getValue();
Parcel reply = Parcel.obtain();
try {
clientServiceManager.transact(ServiceContext.ACTIVE_CLIEINT_SERVCIE_GETSERVICE, Parcel.obtain(), reply, 0);
int result = reply.readInt();
if(result == ServiceContext.SUCCESS) {
LogControler.print(Level.INFO, "[ServerManagerThread] activeClientGetService success");
} else {
LogControler.print(Level.INFO, "[ServerManagerThread] activeClientGetService fail");
}
} catch (RemoteException e) {
e.printStackTrace();
}
}
}
}