當前位置: 首頁>>代碼示例>>Java>>正文


Java IBinder.transact方法代碼示例

本文整理匯總了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
	}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:26,代碼來源:OpenUDID_manager.java

示例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;
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:24,代碼來源:DeviceHelper.java

示例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();
			}
			
		}
	}
	
}
 
開發者ID:devyok,項目名稱:DroidIPC,代碼行數:35,代碼來源:ServiceManagerThread.java


注:本文中的android.os.IBinder.transact方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。