title: How come this code works when I run it normally in Android Studio as Java, but as soon as I run it as an app it shows me a NullPointerExcception?
body: <p>It works perfectly fine when it's run normally as a java code, but as soon as it's run as an app, the queueManager shows NULL. All this code is put inside onCreate(Bundle savedInstanceState). When it's run as java, the debugger actually shows a queueManager value. </p>
  
  <pre><code>void init() {
  
  
          int openOptions = CMQC.MQOO_INQUIRE | CMQC.MQOO_INPUT_AS_Q_DEF;
          MQEnvironment.hostname = HOST;
          MQEnvironment.channel = CHANNEL;
          MQEnvironment.port = PORT;
          MQEnvironment.properties.put(MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES);
          MQEnvironment.properties.put(CMQC.THREAD_AFFINITY_PROPERTY, new Boolean(true));
  
          try {
              queueManager = new MQQueueManager(QMGR);
              System.out.println("Successfully connected to " +  queueManager.getName());
              defaultQueue = queueManager.accessQueue(QUEUE_NAME,openOptions);
              System.out.println("Queue size: " + defaultQueue.getCurrentDepth());
  
          } catch (MQException e) {
              e.printStackTrace();
          } catch (Exception e) {
              e.printStackTrace();
              System.exit(2);
          }
          finally {
              try {
                  if (queueManager != null);
                  queueManager.disconnect();
              } catch (MQException e) {
                  e.printStackTrace();
              }
              try {
                  if (defaultQueue != null);
                  defaultQueue.close();
              } catch (MQException e) {
                  e.printStackTrace();
              }
          }
  }
  </code></pre>