0

I'm trying to layout Inflate in a service on onCreate with this code:

// ...
public void onCreate() {    
    telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
    call = new PhoneCall();

    IntentFilter intentFilter = new IntentFilter(outgoingIntent);
    registerReceiver(callReceiver, intentFilter);

    final LayoutInflater myInflator = (LayoutInflater) ctext.getSystemService(Context.LAYOUT_INFLATER_SERVICE );        

    onPhoneStatelistener = new PhoneStateListener() {
        @Override
        public void onCallStateChanged(int state, String incomingNumber) {

// ...

Here is my log cat:

04-22 02:38:35.324: E/AndroidRuntime(28837): FATAL EXCEPTION: main
04-22 02:38:35.324: E/AndroidRuntime(28837): java.lang.RuntimeException: Unable to create service com.castello.AllMyCalls.CallService: java.lang.NullPointerException
04-22 02:38:35.324: E/AndroidRuntime(28837):    at android.app.ActivityThread.handleCreateService(ActivityThread.java:1959)
04-22 02:38:35.324: E/AndroidRuntime(28837):    at android.app.ActivityThread.access$2500(ActivityThread.java:117)
04-22 02:38:35.324: E/AndroidRuntime(28837):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:989)

I'm just getting a "Null Pointer" error. Any suggestions?

Simon MᶜKenzie
  • 8,344
  • 13
  • 50
  • 77
Reza_Rg
  • 3,345
  • 7
  • 32
  • 48

1 Answers1

0

When i try to get LayoutInflater in service, i usually do like this :

LayoutInflater inflater = LayoutInflater.from(Context);

Hope this might work for you!

Nari Kim Shin
  • 2,459
  • 1
  • 25
  • 33