Today was going to do a short-rate intercept, according to the truth it is very simple ah, this example on the net catch a lot, usually there are two ways:
1. Acceptance of broadcasts 2. Listen to the SMS database, I chose the first way: Accept the broadcast
Give an example: http://www.cnblogs.com/GarfieldTom/archive/2012/08/25/2655609.html
But I met some of the more wonderful problems: Dead or Alive to intercept text messages, so I in the Broadcast class receive () method to print some of the log, Strange is, unexpectedly find those logs, meaning is not received broadcast
Let me tell you: It's about your Mainactity.java .
The key place is here: My Mainactity.java code is as follows
Import Android.support.v7.app.actionbaractivity;import Android.os.bundle;public class Mainactivity extends actionbaractivity { @Override protected void OnCreate (Bundle savedinstancestate) { super.oncreate (savedinstancestate) ; Setcontentview (R.layout.activity_main); finish (); }}
Yes, it is to inherit the actionbaractivity, change him to activity is OK! Some people ask again, this and accept not to receive the broadcast seems to be OK, here I want to ask you to understand why appear actionbaractivity
Short-term intercept failed, unable to access broadcast