= (connectivitymanager) getsystemservice (Connectivity_service);Networkinfo mobnetinfo = Connectmgr.getnetworkinfo (connectivitymanager.type_mobile);Networkinfo wifinetinfo = Connectmgr.getnetworkinfo (Connectivitymanager.type_wifi);if (!mobnetinfo.isconnected () !wifinetinfo.isconnected ()) {LOG.I (TAG, "unconnect");Unconnect Network}else {Connect Network}}};Copy Code2, register receiver in the appropriate place, you can register in the program, call the following function in OnCreate:Intentfi
Ideas:1. Since we are not sure when there will be a call, we should use the service to listen for incoming calls.2. Cancel the monitoring when the service is closed3. Set the checkbox status on the page by opening and closing the service.Listening to incoming calls via services
Create a class that inherits from the service
In the OnCreate method, perform a listener operation on the incoming call:1) Telephonymanager manager = Getsystemserv
Core code:Imei = ((Telephonymanager) Getsystemservice (Telephony_service)). Getdeviceid ();1. Permission to joinIn the Manifest.xml file, add 2, the code is as follows:/** * *@authorDingran * created on 2010-4-29 pm 05:02:47 **/ PackageNet.sunniwell.app; Importandroid.app.Activity; ImportAndroid.os.Bundle; Importandroid.telephony.CellLocation; ImportAndroid.telephony.PhoneStateListener; ImportAndroid.telephony.TelephonyManager; Public classTelman
The simple base station positioning program describes how to obtain the current base station location in detail. The following is a brief summary:
In the Android operating system, base station positioning is actually very simple. let's first talk about the implementation process:
Call the API (telephonymanager) in the SDK to obtain information such as MCC, MNC, LAC, and CID, and then use the Google API to obtain the longitude and latitude of the loca
1. IMEI
IMEI (International Mobile Equipment Identity) is the abbreviation of international mobile device identity code. It is an "electronic serial number" consisting of 15 digits ", it corresponds to each mobile phone, and the code is the only one in the world. Each mobile phone is assigned a unique group of numbers in the world after it is assembled. This number will be recorded by the manufacturer who manufactures it from production to delivery.
Android IMEI Acquisition Method
Copy codeThe Code is as follows: ConnectivityManager mConnectivity = (ConnectivityManager) getSystemService (Context. CONNECTIVITY_SERVICE );
TelephonyManager mTelephony = (TelephonyManager) this. getSystemService (TELEPHONY_SERVICE );
// Check the network connection. If no network is available, no network connection is required.
NetworkInfo info = mConnectivity. getActiveNetworkInfo ();
If (info = null |!
onDestroy (), unregitster;
In onStart (), in onStop (), unregitster;
In onResume (), in onPause (), unregitster;
(2) Forget unregister
I have seen a piece of code before. I defined a PhoneStateListener object in the Activity and registered it to TelephonyManager:
TelephonyManager. listen (l, PhoneStateListener. LISTEN_SERVICE_STATE );
However, when the Activity exits, the listener is canceled, and the foll
. The next two digits (FAC, final assembly COdeIs the "last Assembly number", generally representing the origin
3. the next 6 digits (SNR) are "serial numbers", which generally represent the production sequence numbers.
4. the last 1-digit (SP) is usually "0", which is the Verification Code and is currently in use.
The IMEI code is unique and attached to the logo on the back of the mobile phone. It is read and written to the memory of the mobile phone. It is also the "file" and "ID card number"
The following is the Android read the user number, mobile phone number, SIM card serial number of the implementation code is introduced, need friends can come to refer to the next
1, using the method provided by Telephonymanager, the core code:
Copy Code code as follows:
Telephonymanager TM = (Telephonymanager) this.getsystemservice (Telephony_service);
String I
:
Copy Code code as follows:
if (connectionreceiver!= null) {
Unregisterreceiver (Connectionreceiver);
}
Ps: There are a lot of ways to use Telephonymanager on the Internet, as follows (but I have tried several times to have problems, such as the first time you enter an activity will automatically receive the signal of network disconnect, each time the network state changes to receive multiple callbacks and the state is not
Some mobile phones will have vibration prompts after the phone is connected, which has the advantage of waiting to be connected to the ear to listen to, reduce radiation. This article will talk about how to implement the phone's vibrating cue function on an Android phone, mainly for outgoing calls.
the phone status provided by the Android SDK
Obviously, to have a vibrating cue when the phone is connected, you first need to know when the phone is connected. The Android SDK does not give you a 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.