1

最初のアプリケーションを 2 番目のアプリケーションの画面の一部の領域に表示する必要があるという問題に行き詰まりました。両方のコードは私の管理下にあります。状況についての手がかりが得られないため、どこに進むべきかを誰かに提案してもらえますか。

誰かがこの問題について私を助けてくれたら、それは私にとって大きな助けになるでしょう。

または

S3 で利用可能なマルチスクリーン オプションを使用して、両方のアプリケーションを開くことができれば。

4

1 に答える 1

0

アプリケーションまたは個々のアプリケーションのいずれかにサービスを記述します。AIDL (Android Interface Definition Language) をIRemoteService.aidlとして定義します。以下は私の疑似コードまたはサンプル実装です。このアプローチを使用すると、アクティビティを開始し、アプリケーションを介して別のアプリケーションのイベントを処理できます。

// IRemoteService.aidl

// Declare any non-default types here with import statements

/** Example service interface */
interface IAccountService {
    String getLoggedInUserInfo(String appId);    
    void userLogin(String appId,ILoginCallback cb);    
    void signout(String appId);    
}
interface ILoginCallback {
    void loginSuccess(String userId);
    void loginFailed();
}

あなたのサービスにはいくつかの RemoteCallbacks があります

@Override
public IBinder onBind(Intent intent) {
    final RemoteCallbackList<ILoginCallback> mCallbacks = new RemoteCallbackList<ILoginCallback>();
    if(mCallbacks!=null){
        int i = mCallbacks.beginBroadcast();
        while(i>0){
            i--;
            try {
                Log.e(TAG, "Callback ...");
                mCallbacks.getBroadcastItem(i).loginSuccess(newUserId);
            } catch (RemoteException e) {
                // The RemoteCallbackList will take care of removing                
                // the dead object for us.
            }
        }
        mCallbacks.finishBroadcast();
    }
}

private final IAccountService.Stub mBinder = new IAccountService.Stub() {
        @Override
        public void userLogin(String appId,ILoginCallback cb) throws RemoteException {
            String userId = Settings.getSettings().getUserId();
            if(userId ==null||userId.length()==0){
                mCallbacks.register(cb);
                Intent intent = new Intent(getApplicationContext(), AccountLoginActivity.class);
                intent.putExtra("deviceId", Settings.getSettings().getDeviceUniqueId());
                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                startActivity(intent);
            }
        }
}

以下のリンクで詳細な AIDL の例を見つけることができます。

  1. http://owenhuangtw.pixnet.net/blog/post/23760257-android-aidl-(android-interface-definition-language)
  2. http://www.app-solut.com/blog/2011/04/using-the-android-interface-definition-language-aidl-to-make-a-remote-procedure-call-rpc-in-android/
  3. https://github.com/afollestad/aidl-example
于 2013-06-23T14:43:13.023 に答える