Short-term intercept failed, unable to access broadcast

Source: Internet
Author: User

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

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.