telephone Management Service (TelephonyManager)
Then use the callback method of PhoneStateListenerOnCallStateChanged(Int state, String incomingNumber) for incoming call monitoring (For details, refer to the extended reading section below)
Register a listener
// PhoneServiceName is the service name, generally "phone" --> Context. TELEPHONY_SERVICETelephonyManager telephonyManager = (
int mPhoneType; public int mSysVersion; public String mNetWorkCountryIso; public String mNetWorkOperator; public String mNetWorkOperatorName; public int mNetWorkType; public boolean mIsOnLine; public String mConnectTypeName; public long mFreeMem; public long mTotalMem; public String mCupInfo; public String mProductName; public String mModelName; public String mManufacturerName; /** * priva
Simple implementation of phone bug in android,
Train of Thought:
1. First, you have to run the program in the background, so you need to make the service.
2. How to Implement Telephone listening? first obtain the Phone Manager and then listen on the phone status.
3. Monitor the phone number based on the status of the phone number.
4. You have to start the instance.
5. You cannot close a daemon ..
6. It is automatically enabled in oncreate () in the main activity. This activity does not need page
) { Rect frame = new Rect(); activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(frame); return frame.top; }Obtain the height of the status bar + the height of the title bar (ActionBar)
(Note: If there is no ActionBar, the obtained height will be the same as the above, only the height of the status bar)
public static int getTopBarHeight(Activity activity) { return activity.getWindow().findViewById(Window.ID_ANDROID_CONTENT) .getTop(); }Obtain
Recently, for project reasons, we need to implement an incoming call listener and generate a floating window to prompt relevant information (which is inconvenient to disclose ).
Now let me give a rough picture of my ideas and implementation methods.
To listen for incoming calls, you must first declare "android. Permission. read_phone_state" permission in manifest.
XML Code
You also need to register an incoming call listener. Currently, my solution is to receive the incoming call broadcast
Android development-listening for mobile phone calls
TelephonyManager is a service class that manages the call status and network information of a mobile phone. It provides a large number of getXxx () methods to obtain information about the telephone network. For details about TelephonyManager, refer to Android development to obtain SIM card information of mobile phones.
Program running result:
Log_phone fi
[Android] mobile guard binds a SIM card and androidsim
Update:
If the broadcast cannot be started, it seems that the system of the higher version is disabled.
You can also use adb to send boot broadcasts.
Adb shell am broadcast-a android. intent. action. BOOT_COMPLETED
Not tested yet. Go back and try again.
======================================
Read the serial number of the sim card and save it. If the sim card is changed and the sim card is considered as a thief, a warning is issued.
Read SIM
Android obtains the phone status and listens to the phone call status, and android listens
Get Mobile Phone status:
Import android. content. context; import android. telephony. telephonyManager; // obtain the corresponding system service TelephonyManager tm = (TelephonyManager) getSystemService (Context. TELEPHONY_SERVICE);/*** return call status ** when CALL_ST
Read the SIM card serial number, save it, once the SIM has changed, think it is the thief's SIM card, issued a warning
Read the SIM card serial number
Gets the Telephonymanager object, through Getsystemservice (Telephony_service)
Call the Getsimserialnumber () method of the Telephonymanager object, and get the string type serial number
Keep the serial number in the sharedpreences.
Need to add permissio
Android development-listening for phone calls and android-listening for incoming calls
TelephonyManager is a service class that manages the call status and network information of a mobile phone. It provides a large number of getXxx () methods to obtain information about the telephone network. For details about TelephonyManager, refer to Android development to obtain SIM card information of mobile phones.
Pr
timeTherefore, for commercial use, further modification is required.3 of course, this part of the code has been transplanted to our Home Guard project, and all the problems mentioned in 2 have been solved.Below I will describe the code for the four main contents in the first part.1. TelephonyManager Management in Google Android APIs.TelephonyManager tm = (TelephonyManager) getSystemService (Context. TELEPH
) is a method to obtain array resources in an application. If you want to use the array resources defined in the application, you need to use getResources (). getStringArray (R. array. *). The return value is an array.
Example of the getXxx () method of the TelephonyManager service class
1. TelephonyManager. getDeviceId () // obtain the device ID
2. TelephonyManager
listen_cell_location listen_call_state listen_data_connection_state LISTEN_DA Ta_activity listen_signal_strengths listen_otasp_changed Listen_cell_info can see that these listening messages are and above the Iphonestateliste corresponding to the NER.The client can specify its own state of interest and provide its own callback function for that state, and when the corresponding event occurs, Telephonyregistry invokes the client's callback function. 3.2, client registration monitoring processAs w
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.