Please see the following simple code. I want to display the getLine1Number()
method in the textView
, because the return value from the method is as String
.
But when I run the code in my device, the result is imperceptible.
public class MainActivity extends Activity {
TextView textView;
TelephonyManager telephonyManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textView = (TextView) findViewById(R.id.textView);
telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
String s = telephonyManager.getLine1Number();
textView.setText(s);}
}
And
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>