In the actual engineering application, after entering a special application, a function of the system does not work.
Of course, there are so many ways that this communication can be done. I can think of at least some of the following
1, the use of property familiar to achieve, such words need to add a special attribute;
2, the use of the database. Add a record to the database and set it up when you enter the application. It is also possible to use the content observer in the System section or to infer a reading of this value when a particular event comes up.
3, the use of intent, send a special intent out, in the system to install a filter;
4, using Getrunningtasks, that is, activities service execution information to infer;
The author of the above four kinds, implementation are able to achieve, but the use of the existing system of some information to solve the problem is not better! So the author chooses scenario 4. That is, make an interface. In this interface it is inferred that this particular application is not in the foreground. This is still very practical. Simple code such as the following:
public boolean judgetopactivityisreversevideo (int status) {String topactivityclassname=null; if (AM = = null) am = (Activitymanager) (Mcontext.getsystemservice (Mcontext.activity_service)); list<runningtaskinfo> Runningtaskinfos = am.getrunningtasks (1); if (Runningtaskinfos! = null) {ComponentName f= Runningtaskinfos.get (0). Topactivity;topactivityclassname=f.getclassname ();} SLOG.D (TAG, "# # #topActivityClassName:" +topactivityclassname); if (topactivityclassname!=null&& Topactivityclassname.startswith ("Com.softwinner.reversevideo.ReverseVideo")) {if (1 = = status) mreversevideoappen ter = true;/*in apk, reverse video comming*/else mreversevideoappenter = false;/*in apk, reverse video Outgoing*/re Turn true;} else if (true = = Mreversevideoappenter) {/*enter reversevideo apk, reverse video signal Comming,then Press BA Ck/home key, APK exit, but reverse video signal don't exit, so we need a flag note this special status*/Mreversevid Eoappenter =False return true;} return false; }
I pass the practice test, this method is completely feasible.
Copyright notice: This article blog original article. Blogs, without consent, may not be reproduced.
Special features of Android in special applications to help communication system problems