Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Write a service on either of your application or a individual application. Have <a href="http://developer.android.com/guide/components/aidl.html" rel="nofollow noreferrer">AIDL</a>(Android Interface Definition Language) defined as IRemoteService.aidl, the below is my pseudo code or sample implementation. Using this approach you can start activity and handle events of another application through your application.</p> <pre><code>// 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(); } </code></pre> <p>In your service have some RemoteCallbacks</p> <pre><code>@Override public IBinder onBind(Intent intent) { final RemoteCallbackList&lt;ILoginCallback&gt; mCallbacks = new RemoteCallbackList&lt;ILoginCallback&gt;(); if(mCallbacks!=null){ int i = mCallbacks.beginBroadcast(); while(i&gt;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); } } } </code></pre> <p>You can find detailed AIDL examples in the below links.</p> <ol> <li><a href="http://owenhuangtw.pixnet.net/blog/post/23760257-android-aidl-(android-interface-definition-language)" rel="nofollow noreferrer">http://owenhuangtw.pixnet.net/blog/post/23760257-android-aidl-(android-interface-definition-language)</a></li> <li><a href="http://www.app-solut.com/blog/2011/04/using-the-android-interface-definition-language-aidl-to-make-a-remote-procedure-call-rpc-in-android/" rel="nofollow noreferrer">http://www.app-solut.com/blog/2011/04/using-the-android-interface-definition-language-aidl-to-make-a-remote-procedure-call-rpc-in-android/</a></li> <li><a href="https://github.com/afollestad/aidl-example" rel="nofollow noreferrer">https://github.com/afollestad/aidl-example</a></li> </ol>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload