简体   繁体   English

在android中的列表片段中调用电话管理器

[英]call telephony manager in a list fragment in android

I'm trying to use this code: TelephonyManager telephonyManager; 我正在尝试使用此代码:TelephonyManager telephonyManager;

        telephonyManager  =  ( TelephonyManager )getSystemService( Context.TELEPHONY_SERVICE );
        imeistring = telephonyManager.getDeviceId(); 

to call the id of the phone, but when I'm inside a List Fragment, it gives me errors.. "cannot make a static reference in a non-static method getSystemService(String) from type Activity. 调用手机的ID,但是当我在List Fragment中时,它会给我错误。“无法在类型为Activity的非静态方法getSystemService(String)中创建静态引用。

How else would I be able to get this phone id? 我怎么能得到这个手机ID?

It works in Activity files, but not ListFragments... 它适用于Activity文件,但不适用于ListFragments ......

 telephonyManager  =  ( TelephonyManager )getActivity.getSystemService( Context.TELEPHONY_SERVICE );
 imeistring = telephonyManager.getDeviceId(); 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM