Make sure that you have the following permission set in your Manifest

 <uses-permission android:name="android.permission.READ_PHONE_STATE"/>


With doing this the emulator as well a real device should be able to
get the Line1Number.

Also very your logcat. Without specifying the permission you should
see an error message which indicates what is missing.

07-17 11:51:41.610: ERROR/AndroidRuntime(786): Caused by:
java.lang.SecurityException: Requires READ_PHONE_STATE: Neither user
10020 nor current process has android.permission.READ_PHONE_STATE.

--
Roman Baumgaertner
Sr. SW Engineer-OSDC
·T· · ·Mobile· stick together
The views, opinions and statements in this email are those of the
author solely in their individual capacity, and do not necessarily
represent those of T-Mobile USA, Inc.

On Jul 14, 9:20 pm, desmo84 <[email protected]> wrote:
> Ok, I'm still new to using java and j2me all together, although I
> understand enough to make basic programs and understand what I think
> about returning methods. I'm having trouble with the code below, for
> now all i want my code to do is pull up the MSISDN "telephone number"
> that a mobile device has. Everytime i run the emulator I get an error
> that the app has stopped unexpectedly and to try again. I've modified
> the helloworld demo a little bit and just trying to get the tn to show
> up. please tell me what i've done wrong and can someone also send me
> an article about using the android api's please.
>
> package com.general.AntiClep;
>
> import android.app.Activity;
> import android.os.Bundle;
> import android.widget.TextView;
> import android.telephony.TelephonyManager;
>
> import android.content.Context;
> public class AntiClep extends Activity {
>    /** Called when the activity is first created. */
>   �...@override
>    public void onCreate(Bundle savedInstanceState) {
>
>         String str = null;
>         sum();
>        super.onCreate(savedInstanceState);
>        TextView tv = new TextView(this);
>        tv.setText(str);
>        setContentView(tv);
>    }
>
>    public String sum(){
>            TelephonyManager tm = (TelephonyManager)getSystemService
>            (Context.TELEPHONY_SERVICE);
>
>                 String result = tm.getLine1Number();
>
>                 return result;
>
>    }
>
> }
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" 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-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to