Note that there are some explanatory texts on larger screens.

plurals
  1. POPhone number is not getting displayed
    primarykey
    data
    text
    <p>I have written a simple android application to fetch the phone number... this application is working in Android emulator.... but it is not working in Android mobile phones(both in samsung galaxy s3 and samsung ace).</p> <p>Here is the source code.</p> <p>PhoneNumberActivity.java</p> <pre><code>public class PhoneNumberActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_phone_number); final TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); telephonyManager.getLine1Number(); final Button button = (Button) findViewById(R.id.button1); button.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { TextView textView = (TextView) findViewById(R.id.phoneNumber); textView.setText("Phone Number is :- "+telephonyManager.getLine1Number()); button.setVisibility(Button.INVISIBLE); textView.setVisibility(TextView.VISIBLE); } }); } } </code></pre> <p>AndroidManifest.xml</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.pervazive.phonenumber" android:versionCode="1" android:versionName="1.0" &gt; &lt;uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17" /&gt; &lt;uses-permission android:name="android.permission.READ_PHONE_STATE"/&gt; &lt;application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" &gt; &lt;activity android:name="com.example.phonenumber.PhoneNumberActivity" android:configChanges="orientation|keyboardHidden|screenSize" android:label="@string/app_name" android:theme="@style/FullscreenTheme" &gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;/application&gt; &lt;/manifest&gt; </code></pre> <p>Please let me know what is the problem.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload