Special features of Android in special applications to help communication system problems

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.