Android instance-Mobile security Defender (37)-shows the attribution of the power-off number

Source: Internet
Author: User

First, the goal

Using broadcastreceive to obtain the power-off broadcast, and obtain the power-off number, and then query the database to obtain attribution information;

Second, the code implementation:

1, in the broadcast packet (receiver) under a new class (named Outcallreceiver) inherit broadcastreceive;

2, register in the manifest file, Intent Filter (Inter-filter) to listen for the action is to power off (New_outgoing_call)

Broadcast Recipient Registration Code:

1 <receiver android:name= "Com.example.mobilesafe.receiver.OutCallReceiver" >2             < Intent-filter >3                 <action android:name= "Android.intent.action.NEW_OUTGOING_CALL"/>4              </intent-filter>5         </receiver>
View Code

3, increase the power of monitoring to access (Process_outgoing_calls)

4, in 1 new Class (Outcallreceiver), through the Getresultdata () method to obtain a string type of the power-down number (named Outcallnumb);

5, through the Custom Number Attribution Query Tool Class (Numberaddqueryutils) in the Query method Querynumber (String number) in 4 to pass the numbers obtained in, returns the String type of attribution information, Finally, it can be displayed by toast.

New Class (Outcallreceiver) code:

1  Public classOutcallreceiverextendsBroadcastreceiver {2 3 @Override4      Public voidOnReceive (Context context, Intent Intent) {5         //get the Power off number6String Outcallnumb =Getresultdata ();7         //Querying the database8String Outcalladd =Numberaddqueryutils.querynumber (outcallnumb);9Toast.maketext (Context, Outcalladd, 1). Show ();Ten     } One}
View Code

Android instance-Mobile security Defender (37)-shows the attribution of the power-off number

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.