本文整理了Java中android.telephony.TelephonyManager.getLine1Number()
方法的一些代码示例,展示了TelephonyManager.getLine1Number()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TelephonyManager.getLine1Number()
方法的具体详情如下:
包路径:android.telephony.TelephonyManager
类名称:TelephonyManager
方法名:getLine1Number
暂无
代码示例来源:origin: stackoverflow.com
TelephonyManager tMgr = (TelephonyManager)mAppContext.getSystemService(Context.TELEPHONY_SERVICE);
String mPhoneNumber = tMgr.getLine1Number();
代码示例来源:origin: stackoverflow.com
public class MyClass {
private WebView mAppView;
private DroidGap mGap;
public MyClass(DroidGap gap, WebView view)
{
mAppView = view;
mGap = gap;
}
public String getTelephoneNumber(){
TelephonyManager tm =
(TelephonyManager) mGap.getSystemService(Context.TELEPHONY_SERVICE);
String number = tm.getLine1Number();
return number;
}
}
代码示例来源:origin: stackoverflow.com
TelephonyManager tm = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);
String number = tm.getLine1Number();
代码示例来源:origin: stackoverflow.com
TelephonyManager tMgr = (TelephonyManager)mAppContext.getSystemService(Context.TELEPHONY_SERVICE);
String mPhoneNumber = tMgr.getLine1Number();
代码示例来源:origin: stackoverflow.com
TelephonyManager phoneManager = (TelephonyManager)
getApplicationContext().getSystemService(Context.TELEPHONY_SERVICE);
String phoneNumber = phoneManager.getLine1Number();
代码示例来源:origin: stackoverflow.com
TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
// get IMEI
String imei = tm.getDeviceId();
String phone = tm.getLine1Number();
代码示例来源:origin: stackoverflow.com
TelephonyManager telemamanger = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
String getSimSerialNumber = telemamanger.getSimSerialNumber();
String getSimNumber = telemamanger.getLine1Number();
代码示例来源:origin: square/assertj-android
public TelephonyManagerAssert hasLine1Number(String number) {
isNotNull();
String actualNumber = actual.getLine1Number();
assertThat(actualNumber) //
.overridingErrorMessage("Expected line 1 number <%s> but was <%s>.", number,
actualNumber) //
.isEqualTo(number);
return this;
}
代码示例来源:origin: robolectric/robolectric
@Test
public void shouldGiveLine1Number() {
shadowOf(telephonyManager).setLine1Number("123-244-2222");
assertEquals("123-244-2222", telephonyManager.getLine1Number());
}
代码示例来源:origin: stackoverflow.com
TelephonyManager tMgr = (TelephonyManager)mAppContext.getSystemService(Context.TELEPHONY_SERVICE);
String mPhoneNumber = tMgr.getLine1Number();
代码示例来源:origin: stackoverflow.com
TelephonyManager telephoneMgr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
String phoneNumber = telephoneMgr.getLine1Number();
代码示例来源:origin: oasisfeng/condom
@Test @SuppressLint("HardwareIds") public void testNullDeviceIdKit() throws NameNotFoundException {
final CondomContext condom = CondomContext.wrap(new ContextWrapper(context), "NullDeviceId",
new CondomOptions().addKit(new NullDeviceIdKit()));
final TelephonyManager tm = (TelephonyManager) condom.getSystemService(Context.TELEPHONY_SERVICE);
assertNotNull(tm);
assertTrue(tm.getClass().getName().startsWith(NullDeviceIdKit.class.getName()));
final TelephonyManager app_tm = (TelephonyManager) condom.getApplicationContext().getSystemService(Context.TELEPHONY_SERVICE);
assertNotNull(app_tm);
assertTrue(app_tm.getClass().getName().startsWith(NullDeviceIdKit.class.getName()));
assertPermission(condom, READ_PHONE_STATE, true);
assertNull(tm.getDeviceId());
if (SDK_INT >= LOLLIPOP) {
if (SDK_INT >= M) assertNull(tm.getDeviceId(0));
assertNull(tm.getImei());
assertNull(tm.getImei(0));
if (SDK_INT >= O) assertNull(tm.getMeid());
if (SDK_INT >= O) assertNull(tm.getMeid(0));
}
assertNull(tm.getSimSerialNumber());
assertNull(tm.getLine1Number());
assertNull(tm.getSubscriberId());
}
代码示例来源:origin: stackoverflow.com
TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
// get IMEI
String imei = tm.getDeviceId();
//get The Phone Number
String phone = tm.getLine1Number();
代码示例来源:origin: stackoverflow.com
private String getMyPhoneNumber(){
TelephonyManager mTelephonyMgr;
mTelephonyMgr = (TelephonyManager)
getSystemService(Context.TELEPHONY_SERVICE);
return mTelephonyMgr.getLine1Number();
}
private String getMy10DigitPhoneNumber(){
String s = getMyPhoneNumber();
return s != null && s.length() > 2 ? s.substring(2) : null;
}
代码示例来源:origin: stackoverflow.com
TelephonyManager tMgr = (TelephonyManager)
ShowMyLocation.this.getSystemService(Context.TELEPHONY_SERVICE);
String MyPhoneNumber = "0000000000";
try
{
MyPhoneNumber =tMgr.getLine1Number();
}
catch(NullPointerException ex)
{
}
if(MyPhoneNumber.equals("")){
MyPhoneNumber = tMgr.getSubscriberId();
}
代码示例来源:origin: stackoverflow.com
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.widget.Toast;
public class GetMyPhoneNoActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
String number =getMyPhoneNO();
Toast.makeText(getApplicationContext(), "My Phone No is: "
+number, Toast.LENGTH_SHORT).show();
Log.v("Debug", number);
}
private String getMyPhoneNO(){
TelephonyManager mTelephonyMgr;
mTelephonyMgr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
String yourNumber = mTelephonyMgr.getLine1Number();
//return yourNumber;
}
代码示例来源:origin: stackoverflow.com
TelephonyManager mTelephonyMgr;
mTelephonyMgr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
if (!mTelephonyMgr.getLine1Number().contains(aContact.getPhoneNum()))
代码示例来源:origin: ac-pm/Inspeckage
li.add(new FingerprintItem("TelephonyManager", "IMEI", mTelephonyManager.getDeviceId(), mTelephonyManager.getDeviceId(), false));
li.add(new FingerprintItem("TelephonyManager", "IMSI", mTelephonyManager.getSubscriberId(), mTelephonyManager.getSubscriberId(), false));
li.add(new FingerprintItem("TelephonyManager", "PhoneNumber", mTelephonyManager.getLine1Number(), mTelephonyManager.getLine1Number(), false));
li.add(new FingerprintItem("TelephonyManager", "SimSerial", mTelephonyManager.getSimSerialNumber(), mTelephonyManager.getSimSerialNumber(), false));
li.add(new FingerprintItem("TelephonyManager", "CarrierCode", mTelephonyManager.getNetworkOperator(), mTelephonyManager.getNetworkOperator(), false));
代码示例来源:origin: Trumeet/MiPushFramework
@Test @SuppressLint("HardwareIds") public void testNullDeviceIdKit() {
final CondomContext condom = CondomContext.wrap(new ContextWrapper(context), "NullDeviceId",
new CondomOptions().addKit(new NullDeviceIdKit()));
final TelephonyManager tm = (TelephonyManager) condom.getSystemService(Context.TELEPHONY_SERVICE);
assertTrue(condom.getApplicationContext().getSystemService(Context.TELEPHONY_SERVICE).getClass().getName().startsWith(NullDeviceIdKit.class.getName()));
assertPermission(condom, READ_PHONE_STATE, true);
assertNull(tm.getDeviceId());
if (SDK_INT >= M) assertNull(tm.getDeviceId(0));
assertNull(tm.getImei());
assertNull(tm.getImei(0));
if (SDK_INT >= O) assertNull(tm.getMeid());
if (SDK_INT >= O) assertNull(tm.getMeid(0));
assertNull(tm.getSimSerialNumber());
assertNull(tm.getLine1Number());
assertNull(tm.getSubscriberId());
}
代码示例来源:origin: stackoverflow.com
TelephonyManager tMgr = (TelephonyManager)
ShowMyLocation.this.getSystemService(Context.TELEPHONY_SERVICE);
String MyPhoneNumber = "0000000000";
try
{
MyPhoneNumber =tMgr.getLine1Number();
}
catch(NullPointerException ex)
{
}
if(MyPhoneNumber.equals(""))
MyPhoneNumber = tMgr.getSubscriberId();
内容来源于网络,如有侵权,请联系作者删除!