In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
AIDL: application programming interface definition language
Note: whenever you create or modify an AIDL file, you need to execute the Build- > Rebuild Project action to take effect.
1. Control the Service of another App through one App
Set a widget with intent in the MainActivity of the App to be called. The parameter is the name of the widget, one is the name of the package to be called, and the other is the name of the service class that is called.
Then use startService and stopService in the MainActivity of the App to be called to control the Service of another program.
Second, bind the Service of another App through one App
On the basis of the above, create a new AIDL file in the called App
Re-onBind the method in the called service class, and the return value implements the method of the interface generated by the newly created AIDL file.
In the called MainActivity, I communicate with the Service I learned before, using bindService and unbindService methods, and of course, I also implement onServiceConnected and onServiceDisconnected methods. You can see my previous blog.
Third, synchronize data to the bound Service
1) write another method setData in the interface created by AIDL and implement it in MyService
2) in the called App, you need to create the same file as the called AIDL file
3) the binder of the class that creates an AIDL file in the MainActivity of the called App
IAppServiceRemoteBinder binder=null
4) associate binder with service in the onServiceConnected method
Using binder.setData method to transfer data to binder to complete communication
Binder.setData (edt.getText () .toString ())
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.