Search code examples
androidandroid-contexttelephonymanager

TelephonyManager instantiation


I can't seem to be able to declare a TelephonyManager in android, this is what I'm trying to do:

TelephonyManager tele = Context.getSystemService(Context.TELEPHONY_SERVICE);

Am I doing this right?


Solution

  • Your forgetting to cast. It should look like this:

    TelephonyManager tele = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);