我尝试使用此功能获取电话号码,但它返回一个空字符串。 谁能帮我吗?
private String getPhoneNumber(){
TelephonyManager mTelephonyManager;
mTelephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
return mTelephonyManager.getLine1Number();
}
创建时:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_nuevo6);
mP.setNumber(getPhoneNumber());
Log.i("number",mp.getNumber());
}
});
}