Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8293821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T13:57:58+00:00 2026-06-08T13:57:58+00:00

The code below ends in a nullPointerException when run. The logcat is first, the

  • 0

The code below ends in a nullPointerException when run.

The logcat is first, the code is second.

Logcat:

     07-27 09:58:13.705: D/AndroidRuntime(18164): Shutting down VM
    0

        7-27 09:58:13

.705: W/dalvikvm(18164): threadid=1: thread exiting with uncaught exception (group=0x40a3c1f8)
    07-27 09:58:13.710: E/AndroidRuntime(18164): FATAL EXCEPTION: main
    07-27 09:58:13.710: E/AndroidRuntime(18164): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.liamwli.smsbusy/com.liamwli.smsbusy.Sms_busyActivity}: java.lang.NullPointerException
    07-27 09:58:13.710: E/AndroidRuntime(18164):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2079)
    07-27 09:58:13.710: E/AndroidRuntime(18164):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2104)
    07-27 09:58:13.710: E/AndroidRuntime(18164):    at android.app.ActivityThread.access$600(ActivityThread.java:132)
    07-27 09:58:13.710: E/AndroidRuntime(18164):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1157)
    07-27 09:58:13.710: E/AndroidRuntime(18164):    at android.os.Handler.dispatchMessage(Handler.java:99)
    07-27 09:58:13.710: E/AndroidRuntime(18164):    at android.os.Looper.loop(Looper.java:137)
    07-27 09:58:13.710: E/AndroidRuntime(18164):    at android.app.ActivityThread.main(ActivityThread.java:4575)
    07-27 09:58:13.710: E/AndroidRuntime(18164):    at java.lang.reflect.Method.invokeNative(Native Method)
    07-27 09:58:13.710: E/AndroidRuntime(18164):    at java.lang.reflect.Method.invoke(Method.java:511)
    07-27 09:58:13.710: E/AndroidRuntime(18164):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
    07-27 09:58:13.710: E/AndroidRuntime(18164):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
    07-27 09:58:13.710: E/AndroidRuntime(18164):    at dalvik.system.NativeStart.main(Native Method)
    07-27 09:58:13.710: E/AndroidRuntime(18164): Caused by: java.lang.NullPointerException
    07-27 09:58:13.710: E/AndroidRuntime(18164):    at com.liamwli.smsbusy.Sms_busyActivity.doCheck(Sms_busyActivity.java:142)
    07-27 09:58:13.710: E/AndroidRuntime(18164):    at com.liamwli.smsbusy.Sms_busyActivity.onCreate(Sms_busyActivity.java:60)
    07-27 09:58:13.710: E/AndroidRuntime(18164):    at android.app.Activity.performCreate(Activity.java:4465)
    07-27 09:58:13.710: E/AndroidRuntime(18164):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
    07-27 09:58:13.710: E/AndroidRuntime(18164):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2033)
    07-27 09:58:13.710: E/AndroidRuntime(18164):    ... 11 more
    07-27 09:58:14.035: I/dalvikvm(18164): threadid=3: reacting to signal 3
    07-27 09:58:14.055: I/dalvikvm(18164): Wrote stack traces to '/data/anr/traces.txt'
    07-27 09:58:14.260: I/dalvikvm(18164): threadid=3: reacting to signal 3
    07-27 09:58:14.275: I/dalvikvm(18164): Wrote stack traces to '/data/anr/traces.txt'
    07-27 10:01:17.450: D/AndroidRuntime(18326): Shutting down VM
    07-27 10:01:17.455: W/dalvikvm(18326): threadid=1: thread exiting with uncaught exception (group=0x40a3c1f8)
    07-27 10:01:17.455: E/AndroidRuntime(18326): FATAL EXCEPTION: main
    07-27 10:01:17.455: E/AndroidRuntime(18326): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.liamwli.smsbusy/com.liamwli.smsbusy.Sms_busyActivity}: java.lang.NullPointerException
    07-27 10:01:17.455: E/AndroidRuntime(18326):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2079)
    07-27 10:01:17.455: E/AndroidRuntime(18326):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2104)
    07-27 10:01:17.455: E/AndroidRuntime(18326):    at android.app.ActivityThread.access$600(ActivityThread.java:132)
    07-27 10:01:17.455: E/AndroidRuntime(18326):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1157)
    07-27 10:01:17.455: E/AndroidRuntime(18326):    at android.os.Handler.dispatchMessage(Handler.java:99)
    07-27 10:01:17.455: E/AndroidRuntime(18326):    at android.os.Looper.loop(Looper.java:137)
    07-27 10:01:17.455: E/AndroidRuntime(18326):    at android.app.ActivityThread.main(ActivityThread.java:4575)
    07-27 10:01:17.455: E/AndroidRuntime(18326):    at java.lang.reflect.Method.invokeNative(Native Method)
    07-27 10:01:17.455: E/AndroidRuntime(18326):    at java.lang.reflect.Method.invoke(Method.java:511)
    07-27 10:01:17.455: E/AndroidRuntime(18326):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
    07-27 10:01:17.455: E/AndroidRuntime(18326):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
    07-27 10:01:17.455: E/AndroidRuntime(18326):    at dalvik.system.NativeStart.main(Native Method)
    07-27 10:01:17.455: E/AndroidRuntime(18326): Caused by: java.lang.NullPointerException
    07-27 10:01:17.455: E/AndroidRuntime(18326):    at com.liamwli.smsbusy.Sms_busyActivity.doCheck(Sms_busyActivity.java:142)
    07-27 10:01:17.455: E/AndroidRuntime(18326):    at com.liamwli.smsbusy.Sms_busyActivity.onCreate(Sms_busyActivity.java:60)
    07-27 10:01:17.455: E/AndroidRuntime(18326):    at android.app.Activity.performCreate(Activity.java:4465)
    07-27 10:01:17.455: E/AndroidRuntime(18326):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
    07-27 10:01:17.455: E/AndroidRuntime(18326):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2033)
    07-27 10:01:17.455: E/AndroidRuntime(18326):    ... 11 more
    07-27 10:01:17.855: I/dalvikvm(18326): threadid=3: reacting to signal 3
    07-27 10:01:17.860: I/dalvikvm(18326): Wrote stack traces to '/data/anr/traces.txt'
    07-27 10:01:17.990: I/dalvikvm(18326): threadid=3: reacting to signal 3
    07-27 10:01:17.995: I/dalvikvm(18326): Wrote stack traces to '/data/anr/traces.txt'
    07-27 10:04:32.645: D/AndroidRuntime(18561): Shutting down VM
    07-27 10:04:32.645: W/dalvikvm(18561): threadid=1: thread exiting with uncaught exception (group=0x40a3c1f8)
    07-27 10:04:32.645: E/AndroidRuntime(18561): FATAL EXCEPTION: main
    07-27 10:04:32.645: E/AndroidRuntime(18561): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.liamwli.smsbusy/com.liamwli.smsbusy.Sms_busyActivity}: java.lang.NullPointerException
    07-27 10:04:32.645: E/AndroidRuntime(18561):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2079)
    07-27 10:04:32.645: E/AndroidRuntime(18561):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2104)
    07-27 10:04:32.645: E/AndroidRuntime(18561):    at android.app.ActivityThread.access$600(ActivityThread.java:132)
    07-27 10:04:32.645: E/AndroidRuntime(18561):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1157)
    07-27 10:04:32.645: E/AndroidRuntime(18561):    at android.os.Handler.dispatchMessage(Handler.java:99)
    07-27 10:04:32.645: E/AndroidRuntime(18561):    at android.os.Looper.loop(Looper.java:137)
    07-27 10:04:32.645: E/AndroidRuntime(18561):    at android.app.ActivityThread.main(ActivityThread.java:4575)
    07-27 10:04:32.645: E/AndroidRuntime(18561):    at java.lang.reflect.Method.invokeNative(Native Method)
    07-27 10:04:32.645: E/AndroidRuntime(18561):    at java.lang.reflect.Method.invoke(Method.java:511)
    07-27 10:04:32.645: E/AndroidRuntime(18561):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
    07-27 10:04:32.645: E/AndroidRuntime(18561):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
    07-27 10:04:32.645: E/AndroidRuntime(18561):    at dalvik.system.NativeStart.main(Native Method)
    07-27 10:04:32.645: E/AndroidRuntime(18561): Caused by: java.lang.NullPointerException
    07-27 10:04:32.645: E/AndroidRuntime(18561):    at com.liamwli.smsbusy.Sms_busyActivity.doCheck(Sms_busyActivity.java:140)
    07-27 10:04:32.645: E/AndroidRuntime(18561):    at com.liamwli.smsbusy.Sms_busyActivity.onCreate(Sms_busyActivity.java:58)
    07-27 10:04:32.645: E/AndroidRuntime(18561):    at android.app.Activity.performCreate(Activity.java:4465)
    07-27 10:04:32.645: E/AndroidRuntime(18561):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
    07-27 10:04:32.645: E/AndroidRuntime(18561):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2033)
    07-27 10:04:32.645: E/AndroidRuntime(18561):    ... 11 more
    07-27 10:04:33.060: I/dalvikvm(18561): threadid=3: reacting to signal 3
    07-27 10:04:33.065: I/dalvikvm(18561): Wrote stack traces to '/data/anr/traces.txt'
    07-27 10:04:33.185: I/dalvikvm(18561): threadid=3: reacting to signal 3
    07-27 10:04:33.215: I/dalvikvm(18561): Wrote stack traces to '/data/anr/traces.txt'
    07-27 10:04:36.915: I/Process(18561): Sending signal. PID: 18561 SIG: 9

Line 140 is the mChecker.checkAccess line new line under the last bracket:

private void doCheck() {
        mChecker.checkAccess(mLicenseCheckerCallback);
    }

Line 58 is the call to the doCheck method:

doCheck();

The rest of the class is below:

package com.liamwli.smsbusy;

import com.google.android.vending.licensing.LicenseChecker;
import com.google.android.vending.licensing.LicenseCheckerCallback;
import com.google.android.vending.licensing.Policy;
import com.google.android.vending.licensing.StrictPolicy;

import android.app.Activity;
import android.app.AlertDialog;
import android.os.Bundle;
import android.os.Handler;
import android.preference.PreferenceManager;
import android.provider.Settings.Secure;
import android.util.Log;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.Toast;
import android.widget.ToggleButton;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;

public class Sms_busyActivity extends Activity {
    IntentFilter intentFilter;
    ToggleButton endis;
    EditText message;
    Button smessage;
    SharedPreferences getPrefs;
    SharedPreferences.Editor editor;
    private LicenseCheckerCallback mLicenseCheckerCallback;
    private LicenseChecker mChecker;
    private Handler mHandler;

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        String android_id = Secure.getString(getBaseContext()
                .getContentResolver(), Secure.ANDROID_ID);

        // if (!android_id.contentEquals("56d330123953677d")) {
        // Log.e("SMS Busy App", "Device ID not allowed. Exiting.");
        // finish();
        // } else {

        // Log.d("SMS Busy App", "Device ID Allowed");
        // }

        // Intent i = new Intent("com.liamwli.smsbusy.PREFS");
        // startActivity(i);
        setContentView(R.layout.def);

        doCheck();

        String KEY = "abcdefgijklmnopqrstuvqxyz"; //made up to post online

        endis = (ToggleButton) findViewById(R.id.enableddis);

        smessage = (Button) findViewById(R.id.savemess);

        message = (EditText) findViewById(R.id.message);

        getPrefs = PreferenceManager
                .getDefaultSharedPreferences(getBaseContext());

        editor = getPrefs.edit();

        mLicenseCheckerCallback = new MyLicenseCheckerCallback();

        final byte[] SALT = new byte[] { -46, 65, 30, -128, -103, -57, 74, -64,
                51, 88, -95, -45, 77, -117, -36, -113, -11, 32, -64, 89 };

        mChecker = new LicenseChecker(this, new StrictPolicy(), KEY);

        mHandler = new Handler();

        // ---intent to filter for SMS messages received---
        intentFilter = new IntentFilter();
        intentFilter.addAction("SMS_RECEIVED_ACTION");

        Boolean state = getPrefs.getBoolean("enabled", false);

        // String stext = getPrefs.getString("text", "");

        // message.setText(stext);
        message.setText(getPrefs.getString("text", ""));

        if (message.getText().toString().contentEquals("")) {
            Toast.makeText(this, "Unable to get saved message. Please resave.",
                    Toast.LENGTH_LONG).show();
        }

        endis.setChecked(state);

        endis.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

            @Override
            public void onCheckedChanged(CompoundButton arg0, boolean arg1) {
                // TODO Auto-generated method stub

                Log.d("SMS Busy App", "onCheckedChanged Called");

                // Toast.makeText(Sms_busyActivity.this, "App state changed",
                // Toast.LENGTH_LONG).show();
                editor = getPrefs.edit();
                if (endis.isChecked()) {
                    editor.putBoolean("enabled", true);
                } else {
                    editor.putBoolean("enabled", false);
                }
                editor.putString("text", message.getText().toString());
                editor.commit();

            }
        });

        smessage.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View arg0) {
                // TODO Auto-generated method stub
                editor = getPrefs.edit();
                editor.putString("text", message.getText().toString());
                editor.commit();
                Log.d("smessage", "Message saved & commited");
                Toast.makeText(Sms_busyActivity.this, "Message Saved",
                        Toast.LENGTH_SHORT).show();

            }
        });

    }

    private void doCheck() {
        mChecker.checkAccess(mLicenseCheckerCallback);
    }

    @SuppressWarnings("deprecation")
    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (Integer.parseInt(android.os.Build.VERSION.SDK) < 5
                && keyCode == KeyEvent.KEYCODE_BACK
                && event.getRepeatCount() == 0) {
            Log.d("SMS Busy App", "onKeyDown Called");
            onBackPressed();
        }

        return super.onKeyDown(keyCode, event);
    }

    // public void onBackPressed() {
    // Log.d("SMS Busy App", "onBackPressed Called");
    // finish();

    // }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // TODO Auto-generated method stub
        super.onCreateOptionsMenu(menu);
        Log.d("SMS Busy App", "onCreateOptionsMenu Called");
        getMenuInflater().inflate(R.menu.mmenu, menu);
        return true;

    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // TODO Auto-generated method stub
        super.onOptionsItemSelected(item);

        switch (item.getItemId()) {
        case R.id.aboutme:
            Intent i = new Intent(this, AboutMe.class);
            startActivity(i);
            break;

        }

        return true;
    }

    private void displayResult(final String result) {
        mHandler.post(new Runnable() {
            public void run() {
                Button mCheckLicenseButton = (Button) findViewById(R.id.button1);

                mCheckLicenseButton.setText("App Licenced. Click to continue.");
                mCheckLicenseButton.setEnabled(true);
                setContentView(R.layout.main);
                setProgressBarIndeterminateVisibility(false);

            }
        });
    }

    class MyLicenseCheckerCallback extends Activity implements
            LicenseCheckerCallback {
        public void allow(int reason) {
            if (isFinishing()) {
                // Don't update UI if Activity is finishing.
                return;
            }
            // Should allow user access.
            displayResult(getString(R.string.allow));
        }

        @SuppressWarnings("deprecation")
        public void dontAllow(int reason) {
            if (isFinishing()) {
                // Don't update UI if Activity is finishing.
                return;
            }

            AlertDialog alert = new AlertDialog.Builder(Sms_busyActivity.this)
                    .create();
            if (reason == Policy.RETRY) {
                // If the reason received from the policy is RETRY, it was
                // probably
                // due to a loss of connection with the service, so we should
                // give the
                // user a chance to retry. So show a dialog to retry.
                alert.setTitle("Please retry license check");
                alert.setMessage("The connection to the licensing server was lost. Please click retry below");
                alert.setButton("Retry", new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface arg0, int arg1) {
                        // TODO Auto-generated method stub

                    }
                });
                alert.show();
            } else {
                // Otherwise, the user is not licensed to use this app.
                // Your response should always inform the user that the
                // application
                // is not licensed, but your behavior at that point can vary.
                // You might
                // provide the user a limited access version of your app or you
                // can
                // take them to Google Play to purchase the app.f
                setContentView(R.layout.def);
                alert.setTitle("Not Licensed");
                alert.setMessage("This app is not licensed. Please buy it off google play.");
                alert.setButton("Exit", new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface arg0, int arg1) {
                        // TODO Auto-generated method stub

                    }
                });
                alert.show();
            }
        }

        @Override
        public void applicationError(int errorCode) {
            // TODO Auto-generated method stub

        }
    }




}

EDIT: Line numbers were off. New logcat generated. Please look again.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T13:58:00+00:00Added an answer on June 8, 2026 at 1:58 pm

    You initialise you mChecker after using it :

    mChecker = new LicenseChecker(this, new StrictPolicy(), KEY);
    
    mLicenseCheckerCallback = new MyLicenseCheckerCallback();
    
    doCheck();
    
    String KEY = "abcdefgijklmnopqrstuvqxyz"; //made up to post online
    
    endis = (ToggleButton) findViewById(R.id.enableddis);
    
    smessage = (Button) findViewById(R.id.savemess);
    
    message = (EditText) findViewById(R.id.message);
    
    getPrefs = PreferenceManager
            .getDefaultSharedPreferences(getBaseContext());
    
    editor = getPrefs.edit();
    
    final byte[] SALT = new byte[] { -46, 65, 30, -128, -103, -57, 74, -64,
            51, 88, -95, -45, 77, -117, -36, -113, -11, 32, -64, 89 };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The code below ends up printing failure. try: print request.raw_post_data json_data = simplejson.loads(request.raw_post_data) except:
Code below. The outcome of this is that each document ends up with the
I wrote the code below and I was expecting that, when the first loop
The code below continues many lines until it ends with a expected /veotherwise /vechoose.
I wrote the code below for homework purposes. When I run it on XCode
Hi wonder if anyone could help me. the first code below basically counted every
The code below ends up in a seemingly endless loop while printing some decimal
Code below is working well as long as I have class ClassSameAssembly in same
Code below is used to save PostgreSql database backup from browser in Apache Mono
The code below simply didn't work. document.getElementById('files').addEventListener('change', handleFileSelect, false); reported by firebug that this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.