Hi
I want to get my mobile number for a sim in my mobile.I am using the
following code.But it gives me empty string.

package Get.My.PhoneNumber;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.telephony.TelephonyManager;
import android.widget.TextView;

public class GetMyPhoneNumberActivity extends Activity {
   TextView phn;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        phn = (TextView) findViewById(R.id.phn);
        String s = getMyPhoneNumber();
        phn.setText(s);
    }

    private String getMyPhoneNumber(){
        TelephonyManager mTelephonyMgr;
        mTelephonyMgr =
(TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
        return mTelephonyMgr.getLine1Number();
        }
}

Please suggest me.

Regards
RiskyCoder

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to