First, in the Manifest.xml file to obtain the listening phone permissions, registered monitoring phone activityreceiverAndroid:name=". Phonereceiver "> Intent-filterandroid:priority= "+"> ActionAndroid:name= "Android.intent.action.PHONE_STATE"/> ActionAndroid:name= "Android.intent.action.NEW_OUTGOING_CALL" /> Intent-filter> receiver>1 - 2 android:name= " Android.permission.READ_PHONE_STATE "/>Second, the main problem in the implem
file:Simcardinfo.java:/** * @author Yazhizhao * 20142014-10-22 morning 9:13:04 */package com.example.android_sms;import android.content.Context; Import Android.telephony.telephonymanager;import android.util.log;/** * @author Yazhizhao 20142014-10-22 9:13:04 */ public class Simcardinfo {/** * Telephonymanager provides access to information about the communication service on the device. The application is able to use this class of methods to identify t
Do mobile phone development, presumably want to get mobile phone number bar, Android has a class Android.telephony.TelephonyManager provide this feature.Telephonymanager TM = (Telephonymanager) this.getsystemservice (Context.telephony_service);Numbertext.settext (tm. Getline1number());The red flag function is able to get the native number.In addition, Telephonymanager class also provides a variety of acces
The reflection mechanism needs to be used to reflect itelephony.Private void dial (string number ){Class Method getitelephonymethod = NULL;Try {Getitelephonymethod = C. getdeclaredmethod ("getitelephony ",(Class []) null );Getitelephonymethod. setaccessible (true );} Catch (securityexception e ){// Todo auto-generated Catch BlockE. printstacktrace ();} Catch (nosuchmethodexception e ){// Todo auto-generated Catch BlockE. printstacktrace ();}
Try {Telephonyma
Monitor incoming call statusAudiofocus is a feature available only after android2.2. For versions earlier than Android 2.2, another method is to listen to the phone status. At least when you call in, you can pause the music.The first step to implement this function is to declare the receiver used to receive the phone_state notification in androidmanifest. xml.Step 2: Define a corresponding phonestatereceiver, Code As follows:Package lyricplayer. xwg;Import Android. content. broadcastreceiver;Imp
Method 1:
Obtain the imsi code of the mobile phone and determine whether it is China Mobile, China Unicom, or China Telecom.
Telephonymanager telmanager = (telephonymanager) getsystemservice (context. telephony_service );
/** Get the imsi code of the SIM card
* Unique SIM card ID: imsiImsi: internationalmobileSubscriber identification number) is the identifier for distinguishing mobile users,
* It is stored
) {Try{mservice.setmobiledataenabled (enabled); }Catch(RemoteException e) { } }But open more than 5.0 of the source code, these two methods no longer exist.Recommend a good online to see the source of the website. Online source URL.At this time the boss's reminder helped me, I opened more than 5.0 code of the Telephonymananger class try to get setdataenabled and getdataenabled class through reflection to complete the operation.Source/** @hide * / @SystemApi Public void setdataen
Sdcard and SIM card are used in a project. When using sdcard, You need to determine whether the status can be read and written. When using a SIM card, you must determine whether it is readable. For how to do this, see the following two functions:// Whether sdcard can be read/writtenPublic boolean IsCanUseSdCard (){Try {Return Environment. getExternalStorageState (). equals (Environment. MEDIA_MOUNTED );} Catch (Exception e ){E. printStackTrace ();}Return false;}// Whether the SIM card is readabl
[Android] mobile guard incoming call display number, android incoming call display
Continue the Project N days ago
Enable Service Listening for incoming calls, query the database, and display the location
For more information, see this blog: http://www.cnblogs.com/taoshihan/p/5331232.html
AddressService. java
Package com. qingguow. mobilesafe. service; import com. qingguow. mobilesafe. utils. numberQueryAddressUtil; import android. app. service; import android. content. intent; import android. O
Summary of mobile phone system information, mobile phone system information
Get IMEI number:
/*** Get the IMEI number ** @ Description: * @ param activity * @ param @ return * @ return String */public static String getIMEI (Activity activity) {TelephonyManager manager = (TelephonyManager) activity. getSystemService (Context. TELEPHONY_SERVICE); return manager. getDeviceId ();}
Get IMSI:
/*** Get IMSI *
Android obtains carrier Information
The project requires a three-network release product. The three single-network sdks are automatically integrated into the three networks. The idea is probably to divide the SDK into operators in the OnCreate time zone.
Set enumeration, assign enumeration variables based on the obtained SIM card information, and perform subsequent operations on the three networks based on enumeration.
Set carrier enumeration first
enum CARRIEROPERATOR{NONE(0),MM(1),UNIPAY(2),
(); } return true; } } } return false; }If data is connected through Telephonymanager to obtain data is 3g/4g, unicom or mobile telecommunications and other information/* Get service information from your phone's suppliers * *Telephonymanager Telephonymanager = (telephonymanager
(RemoteException e) {
TODO auto-generated Catch block
E.printstacktrace ();
}
else if (state = = Telephonymanager.call_state_idle) {
Start playing again
if (Mresumeaftercall) {
Resume playback only if music is playing
When the call was answered
try {
Stub.resume ();
catch (RemoteException e) {
TODO auto-generated Catch block
E.printstacktrace ();
}
Mresumeaftercall = false;
}
}
}
};
When it is used, it is added in the oncreate of the service, as follows:
Copy Code c
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.