// Obtain the corresponding system service
Telephonymanager TM = (telephonymanager) getsystemservice (context. telephony_service );
// Use the listen (phonestatelistener listener, int events) of the telephonymanager object)
The first parameter needs to implement the phonestatelistener listener and implement the corresponding method. The second parameter is the st
:
TelephonyManager response = (TelephonyManager) getSystemService (this. TELEPHONY_SERVICE); String imei = mTelephonyMgr. getDeviceId (); System. out. println ("the current Imei is -->" + imei );
Well, the imei of the mobile phone can be obtained through normal software development. You can use the system API.
Then we need to analyze the class where Telephony
, PhoneListenService. class); startService (intent); 1. Enable the telephone listening permission in the service:
Listen to phone status
Monitor SD card status
Write External Storage Device
Mic for recording
Public class PhoneListenService extends Service {public IBinder onBind (Intent intent) {return null;} // 2. the onCreate method executes public void onCreate () {super. onCreate (); setForeground (true); // upgrade to foreground process
How do we get a CDMA or GSM phone signal on Android, where we often easily get a list of WiFi signals?
The system provides the Telephonymanager class, this kind is very rich, basically you need the handset information to be able to obtain, that below to see we need the CDMA and the GSM signal is how obtains.
Private Telephonymanager Telephonymanager;Private Pho
1, using the method provided by Telephonymanager, the core code:
The code is as follows
Copy Code
Telephonymanager TM = (Telephonymanager) this.getsystemservice (Telephony_service);String IMEI = Tm.getdeviceid (); Take out the IMEILOG.D (TAG, "IMEI:" +imei);String Tel = tm.getline1number (); Remove MSISDN, most likely emptyLOG.D (TA
Please follow the steps below to modify it:Frameworks\base\media\java\android\media\mediafocuscontrol.java:1, Import Packages:Import Com.android.internal.telephony.ITelephony;Import Android.os.ServiceManager;2, increase the access to the current phone call state method Getphonecallstate ():private int getphonecallstate () {int phonecallstate = Telephonymanager.call_state_idle;Telephonymanager Telephonymanager
Modify:Frameworks\base\media\java\android\media\mediafocuscontrol.java:1, Import Packages:Import Com.android.internal.telephony.ITelephony;Import Android.os.ServiceManager;2, increase the access to the current phone call state method Getphonecallstate ():private int getphonecallstate () {int phonecallstate = Telephonymanager.call_state_idle;Telephonymanager Telephonymanager = (
, no bright screen locks are released when the problem persists. If Call_STATE_IDLE and Call_State_OFFHooK are locked multiple times, the locks generated each time are different, even if the same lock name is used, however, the lock is not released and will not be pushed to the screen. Therefore, in Call_STATE_IDLE and Call_State_OFFHooK, you must specify that the new lock is only performed once and release the corresponding lock. In this way, after the screen is highlighted, the screen is displ
class MyService extends Service {
/*
* Called during binding
*/
Public IBinder onBind (Intent intent ){
Return null;
}
/*
* Called when the service is enabled
*/
Public void onCreate (){
Super. onCreate ();
System. out. println ("onCreate ");
}
/*
* Called when the service is terminated
*/
Public void onDestroy (){
Super. onDestroy ();
System. out. println ("onDestroy ");
}
}
3. Define the service in the configuration file:
Telephone recording
The telephone recording is implemented by th
The basic idea of listening to the phone status on Android is to register and accept the broadcast of the phone status. The implementation is as follows:
First, you need the following permissions to listen to the phone status:
Second, accept the broadcast of phone status:
Public class phonereceiver extends broadcastreceiver {Private Static final string tag = "phonereceiver"; Public void onreceive (context, intent) {log. I (TAG, "onreceive ()"); string action = intent. getaction (); If (actio
How to obtain a sequence number that uniquely identifies each Android device? There are many answers to this question, but most of them are valid only in some cases. Based on tests:
all devices can return a telephonymanager. getdeviceid ()
A telephonymanager. getsimserialnumber ()
for all CDMA devices, getsimserialnumber () Returns a null value!
All devices with a Google ac
Because android2.3 and above have added restrictions on permission Android. Permission. modify_phone_state, the method of calling itelephone through the reflection mechanism before 2.3 is no longer applicable, so you can use the counterfeit broadcast method to answer the phone.
Package COM. demo. launcher; import Java. lang. reflect. invocationtargetexception; import Java. lang. reflect. method; import android. content. context; import android. content. intent; import android. media. audiomana
components of the Service process user program run in the background4. No service components are running in the Background process application, and the program is in the minimized state.5. The Empty process does not have any activity.The priority is reduced from top to bottom. If the task stack first kills the process, it must first kill the empty process.
The implementation of a telephone bug is to maintain a Service in the background to monitor the user's call status, recording the phone.
1.
Explanation of automatic answering and hanging up for Android phones
1. Call up through aidl and reflectionThere are three steps:
(1) ITelephony. aidl. You must create a new com. android. internal. telephony package and put it into ITelephony. aidl file (after construction, there is ITelephony under gen. java file, which is the interface generated by aidl). The file content is as follows:
Package com. android. internal. telephony;
Interface ITelephony {
Boolean endCall ();
Void answerRingingCall
, and then restart the mobile phone to open the software:
When you click to play a script, the following information is displayed:
The printed information in our hook indicates that everything is normal.
In terms of testing, I just tested several plug-ins, but it was not as long as one hour in a row. If there are other problems in the test, continue to find the cause based on the problem.
0x2: second episode
If you want to spend money in the game, you can only pay for it every day. Theref
When we call a phone, we need to monitor the incoming call of the phone number.CodeControl. Let's take a look at the display of incoming calls using the display feature.
Package com. Smart;Import Android. App. activity;Import Android. content. context;Import Android. OS. Bundle;Import Android. telephony. phonestatelistener;Import Android. telephony. telephonymanager;Import Android. widget. Toast;Public class main extends activity {Public class myphon
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.