Hey,can anyone tell me how to access phone number in sdk 1.0.I am getting
error in starting application. I have used permission  <uses-permission
android:name="android.permission.READ_PHONE_STATE"/> in manifest.I am not
able to find where problem lies.

code is:


import android.app.Activity;
import android.telephony.*;
import android.os.Bundle;
import android.content.*;
import android.widget.*;
public class getphone extends Activity {
    private Context context;
    private TextView tx1,tx2,tx3;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        tx1= (TextView )this.findViewById(R.id.phn_no);
        tx2= (TextView )this.findViewById(R.id.imei_no);
        tx3= (TextView )this.findViewById(R.id.sim_co);
        TelephonyManager mTelephonyMgr =
(TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
        String imei = mTelephonyMgr.getDeviceId();
        String phoneNumber=mTelephonyMgr.getLine1Number();
        String country = mTelephonyMgr.getSimCountryIso();
        System.out.print("no is "+  phoneNumber + " imei "+ imei+
"sim-country "+country );
        tx1.setText(phoneNumber);
        tx2.setText(imei);
        tx3.setTag(country);

    }
}

On Fri, Oct 24, 2008 at 3:58 AM, Danny <[EMAIL PROTECTED]> wrote:

>
> I am trying to get the user's phone number to use as UID and it seems
> to work in the emulator but not in the actual device, is it a bug or
> am I doing something wrong? My piece of code is here...
>
>                                TelephonyManager mTelephonyMgr =
> (TelephonyManager)
> getSystemService(Context.TELEPHONY_SERVICE);
>                                String phoneNum =
> mTelephonyMgr.getLine1Number();
> >
>

--~--~---------~--~----~------------~-------~--~----~
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