title: call android activity method via QAndroidJniObject
body: <p>Hello everybody  I want to call this method &quot;printTextTemplate ()&quot; from an android activity class to Qt via QAndroidJniObject but I can't get it to work. here is my java class below</p>
  <pre><code>package org.qtproject.example.activityhandler;
  
  import android.app.Activity;
  import android.content.Intent;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.Button;
  
  import android.graphics.Bitmap;
  import android.graphics.BitmapFactory;
  import android.graphics.drawable.BitmapDrawable;
  import android.graphics.drawable.Drawable;
  
  import android.bld.print.configuration.PrintConfig;
  import com.example.lc_print_sdk.PrintUtil;
  import com.google.zxing.BarcodeFormat;
  
  import org.qtproject.example.activityhandler.utils.BitmapUtils;
  import org.qtproject.example.activityhandler.R;
  
  import androidx.appcompat.app.AppCompatActivity;
  import androidx.appcompat.widget.Toolbar;
  
  public  class CustomActivity extends Activity {
  
      PrintUtil printUtil;
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.second_activity);
  
          printUtil=PrintUtil.getInstance (this);
          //printUtil.setPrintEventListener (this);
          printUtil.printEnableMark (false);
  
  
  
          Button backButton = (Button) findViewById(R.id.backButton);
          backButton.setOnClickListener(new View.OnClickListener() {
  
              @Override
              public void onClick(View view) {
  
                  String sessionId = &quot;Hello Alioune&quot;;
                  Intent inputIntent = getIntent();
                  sessionId = inputIntent.getStringExtra(&quot;message&quot;);
  
                  //printTextTemplate();
                  Intent resultIntent = new Intent();
                  resultIntent.putExtra(&quot;message&quot;, sessionId);
                  setResult(Activity.RESULT_OK, resultIntent);
                  finish();
              }
          });
      }
  
      public void printTextTemplate() {
  
         BitmapDrawable drawable=(BitmapDrawable) getResources ().getDrawable (R.drawable.a);
         Bitmap bitmap=BitmapUtils.compressPic(drawable.getBitmap(), 350, 160);
         printUtil.printBitmap(bitmap);
  
         printUtil.printText (PrintConfig.Align.ALIGN_CENTER, PrintConfig.FontSize.TOP_FONT_SIZE_MIDDLE, false, false, &quot;------------------------------------------------------\n&quot;);
  
         printUtil.printText (PrintConfig.Align.ALIGN_CENTER, PrintConfig.FontSize.TOP_FONT_SIZE_LARGE, true, true, &quot;CONTROL ROUTIER\n&quot;);
  
         printUtil.printText (PrintConfig.Align.ALIGN_CENTER, PrintConfig.FontSize.TOP_FONT_SIZE_MIDDLE, false, false, &quot;------------------------------------------------------\n&quot;);
  
         printUtil.printText (PrintConfig.Align.ALIGN_LEFT, PrintConfig.FontSize.TOP_FONT_SIZE_MIDDLE, false, false, &quot;Référence:\n\n&quot;);
         printUtil.printText (PrintConfig.Align.ALIGN_LEFT, PrintConfig.FontSize.TOP_FONT_SIZE_MIDDLE, false, false, &quot;Date：\n\n&quot;);
         printUtil.printText (PrintConfig.Align.ALIGN_LEFT, PrintConfig.FontSize.TOP_FONT_SIZE_MIDDLE, false, false, &quot;Validité:\n\n&quot;);
         printUtil.printText (PrintConfig.Align.ALIGN_LEFT, PrintConfig.FontSize.TOP_FONT_SIZE_MIDDLE, false, false, &quot;Agent：\n&quot;);
         printUtil.printLine (1);
  
  
         printUtil.printText (PrintConfig.Align.ALIGN_CENTER, PrintConfig.FontSize.TOP_FONT_SIZE_MIDDLE, false, false, &quot;------------------------------------------------------\n&quot;);
  
         printUtil.printText (PrintConfig.Align.ALIGN_CENTER, PrintConfig.FontSize.TOP_FONT_SIZE_LARGE, true, true, &quot;CAMIONS\n&quot;);
  
         printUtil.printText (PrintConfig.Align.ALIGN_CENTER, PrintConfig.FontSize.TOP_FONT_SIZE_MIDDLE, false, false, &quot;------------------------------------------------------\n&quot;);
  
         printUtil.printText (PrintConfig.Align.ALIGN_LEFT, PrintConfig.FontSize.TOP_FONT_SIZE_MIDDLE, false, false, &quot;Immatriculation:\n\n&quot;);
         printUtil.printText (PrintConfig.Align.ALIGN_LEFT, PrintConfig.FontSize.TOP_FONT_SIZE_MIDDLE, false, false, &quot;Chauffeur：\n\n&quot;);
         printUtil.printText (PrintConfig.Align.ALIGN_LEFT, PrintConfig.FontSize.TOP_FONT_SIZE_MIDDLE, false, false, &quot;Produit Chargé:\n&quot;);
  
         printUtil.printLine (1);
  
  
         printUtil.printText (PrintConfig.Align.ALIGN_CENTER, PrintConfig.FontSize.TOP_FONT_SIZE_MIDDLE, false, false, &quot;------------------------------------------------------\n&quot;);
  
         printUtil.printText (PrintConfig.Align.ALIGN_CENTER, PrintConfig.FontSize.TOP_FONT_SIZE_LARGE, true, true, &quot;CONFIRMATION\n&quot;);
  
         printUtil.printText (PrintConfig.Align.ALIGN_CENTER, PrintConfig.FontSize.TOP_FONT_SIZE_MIDDLE, false, false, &quot;------------------------------------------------------\n&quot;);
  
         BitmapDrawable drawable1=(BitmapDrawable) getResources ().getDrawable (R.drawable.b);
         Bitmap bitmap1=BitmapUtils.compressPic(drawable1.getBitmap(), 300, 300);
         printUtil.printBitmap(bitmap1);
  
         printUtil.printLine (1);
  
         printUtil.printText (PrintConfig.Align.ALIGN_CENTER, PrintConfig.FontSize.TOP_FONT_SIZE_MIDDLE, false, false, &quot;------------------------------------------------------\n&quot;);
  
         printUtil.printText (PrintConfig.Align.ALIGN_CENTER, PrintConfig.FontSize.TOP_FONT_SIZE_LARGE, true, true, &quot;POSTE DE DOUANE BITOU\n&quot;);
  
         printUtil.printText (PrintConfig.Align.ALIGN_CENTER, PrintConfig.FontSize.TOP_FONT_SIZE_MIDDLE, false, false, &quot;------------------------------------------------------\n&quot;);
  
         printUtil.printLine (8);
         printUtil.start ();
     }
  
  }
  </code></pre>
  <p>Here is the method of calling in Qt</p>
  <p>void ActivityHandler::printTextTemplate(){</p>
  <pre><code>QAndroidJniObject javaClass =
  QAndroidJniObject(&quot;org/qtproject/example/activityhandler/CustomActivity&quot;,
  &quot;(Landroid/content/Context;Landroid/app/Activity;)V&quot;,
  QtAndroid::androidContext().object&lt;jobject&gt;(),
  QtAndroid::androidActivity().object&lt;jobject&gt;());
  </code></pre>
  <p>javaClass.callMethod(&quot;printTextTemplate&quot;);
  }</p>