Thanks for the reply, I uses the permission as:
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"
/>
I had test the code TelephonyManager tel =
(TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE) in an activity
and it works well.
2009/11/30 Wojciech Topolski <[email protected]>
> Hi
>
> 2009/11/30 Zhihong GUO <[email protected]>
>
> Hi all,
>>
>> I got an problem on getting the TelephonyManager in my personal service.
>> The code as below:
>>
>> public class MyService extends Service {
>>
>> @Override
>> public IBinder onBind(Intent intent) {
>> return mBinder;
>> }
>>
>> /**
>> * The implementation of IMyService defined through AIDL.
>> */
>> public IBinder mBinder = new IMyService.Stub() {
>>
>> public Map getConfig() {
>> ...
>> TelephonyManager tel =
>> (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
>>
>> ...
>>
>> The code will throw an NullPointerException on the
>> line: (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
>>
>> why??
>>
>
> Maybe permission in AndroidManifest.xml is required? On TelephoneManeger
> website is information: "Note that acess to some telephony information is
> permission-protected. Your application cannot access the protected
> information unless it has the appropriate permissions declared in its
> manifest file. Where permissions apply, they are noted in the the methods
> through which you access the protected information."
>
>
>
> --
> ===============================
> Wojciech Topolski
> [email protected]
> ===============================
>
> --
> 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]<android-developers%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>
--
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