Android Tutorial Accesing third party Jar with #Additionaljar and JavaObject - Picasso

Discussion in 'Tutorials & Examples' started by Erel, May 12, 2014.

  1. DonManfred

    DonManfred Expert Licensed User

    AdditionalJar and AdditionalRes must be in the mainactivity as far as i know
    joilts likes this.
  2. susu

    susu Well-Known Member Licensed User

    I made a simple app with 2 activities:
    1. Main activity with a button to start LoadImage activity.
    2. LoadImage activity has a scrollview with random 20 images (download from internet by using Picasso).

    It works fine but there's only one problem: From Main activity I click on button to start LoadImage activity, if I back to Main activity but the images still loading so it will auto open LoadImage activity again. How can I cancel the loading of images when LoadImage activity closed? I try to remove all ImageView and ScrollView in Sub Activity_Pause but it seems not work.

  3. Erel

    Erel Administrator Staff Member Licensed User

    Please start a new thread for this question.
  4. susu

    susu Well-Known Member Licensed User

  5. PhilipK

    PhilipK Member Licensed User

    Hi, I'm trying to integrate a third party JAR file: thermodosdk-1.0.18

    I can't see from the examples above exactly how to do it; when I'm sure it's straightforward if you know what's to be done.

    The author says you have to :
    1. Declare the proper permissions required by the SDK. (OK done).
    2. Implement a ThermodoListener that will be notified of Thermodo related events
    3. Create a Thermodoinstance and start measuring
    (From the authors site:
    1. Where do I put the JAR file? Into the B4A libraries folder?
    2. I'm confused on how to reference the JAR beyond the obvious: #AdditionalJar: thermodosdk-1.0.18
    3. I have the permissions from their site to add to the manifest

    I have found code that has the package name and also lists the events:

    package com.robocatapps.thermodosdk.sample;

    import android.os.Bundle;
    import android.widget.TextView;
    import android.widget.Toast;

    import com.robocatapps.thermodosdk.Thermodo;
    import com.robocatapps.thermodosdk.ThermodoFactory;
    import com.robocatapps.thermodosdk.ThermodoListener;

    import java.util.logging.Logger;

    public class MainActivity extends Activity implements ThermodoListener {

    private static Logger sLog = Logger.getLogger(MainActivity.class.getName());
    private Thermodo mThermodo;
    private TextView mTemperatureTextView;

        protected void onCreate(Bundle savedInstanceState) {

            mTemperatureTextView = (
    TextView) findViewById(;
            mThermodo = ThermodoFactory.getThermodoInstance(this);

        public void onStartedMeasuring() {
            Toast.makeText(this, "Started measuring", Toast.LENGTH_SHORT).show();
  "Started measuring");

        public void onStoppedMeasuring() {
            Toast.makeText(this, "Stopped measuring", Toast.LENGTH_SHORT).show();
  "Stopped measuring");

        public void onTemperatureMeasured(float temperature) {
            sLog.fine("Got temparature: " + temperature);

        public void onErrorOccurred(int what) {
            Toast.makeText(this, "An error has occurred: " + what, Toast.LENGTH_SHORT).show();
            switch (what) {
                case Thermodo.ERROR_AUDIO_FOCUS_GAIN_FAILED:
                    sLog.severe("An error has occurred: Audio Focus Gain Failed");
                case Thermodo.ERROR_AUDIO_RECORD_FAILURE:
                    sLog.severe("An error has occurred: Audio Record Failure");
                case Thermodo.ERROR_SET_MAX_VOLUME_FAILED:
                    sLog.warning("An error has occurred: The volume could not be set to maximum");
                    sLog.severe("An unidentified error has occurred: " + what);

        protected void onStart() {

        protected void onStop() {
    How does it fit together? I can take the embarrassment,... I hope.

    Thanks in advance
  6. Erel

    Erel Administrator Staff Member Licensed User

    1. In the additional libraries folder.
    2. You need to use JavaObject for that. It is not so simple. You do need some Java knowledge for this.
  7. Jordi Casas Armengol

    Jordi Casas Armengol Member Licensed User

    I'm trying to use Glide library but I can't load an image into a Bitmap, only on an ImageView. This works:

    The ImageView is shown correctly if I assign it to activity background, but if I try to get the associated bitmap (myImageView(i).Bitmap) it returns null.

    Anybody has a solution?
  8. tagwato

    tagwato Member Licensed User

    Anyone succeeded in running the exact code in post # 1 (complete code) ?
    Tried (B4A 5.80) in emulator and real device, no success. Images are not loaded and callback method name always gets "on error".
    The url is Ok, we can see the image in the browser.
    Any tip?
  9. Erel

    Erel Administrator Staff Member Licensed User

    Just tried it now and it works.
  10. ppgirl

    ppgirl Member Licensed User

    Erel , How to deal with @override instead of createEvent ?

    I found a library need callback by @override function from the classes , I did not find other interface .

    please suggest the javaobject usage . thanks!

    private void getYoutubeDownloadUrl(String youtubeLink) {
    YouTubeUriExtractor ytEx = new YouTubeUriExtractor(this) {
    public void onUrisAvailable(String videoId, String videoTitle, SparseArray<YtFile> ytFiles) {
    if (ytFiles == null) {
    // Something went wrong we got no urls. Always check this.
    // Iterate over itags
    for (int i = 0, itag = 0; i < ytFiles.size(); i++) {
    itag = ytFiles.keyAt(i);
    // ytFile represents one file with its url and meta data
    YtFile ytFile = ytFiles.get(itag);
    // Just add videos in a decent format => height -1 = audio
    if (ytFile.getMeta().getHeight() == -1 || ytFile.getMeta().getHeight() >= 360) {
    addButtonToMainLayout(videoTitle, ytFile);
    // Ignore the webm container format
    // Lets execute the request
  11. Erel

    Erel Administrator Staff Member Licensed User

    It is not possible to do it with CreateEvent. You need to use inline java for this or write a small library (simpler).
  12. scsjc

    scsjc Well-Known Member Licensed User

    it's possible get the ... ImageView.bitmap ... on event Callback_Event,
    and process the bitmap to have RoundBitmap with NativeMe.Runmethod("getRoundBitmap"......

    (the idea is make a roundbitmap imageview obtain by picasso jar)
  13. Erel

    Erel Administrator Staff Member Licensed User

  14. peacemaker

    peacemaker Well-Known Member Licensed User

  15. Erel

    Erel Administrator Staff Member Licensed User

    Yes. The .so files should be in the jar so they will be copied to the APK.
  16. peacemaker

    peacemaker Well-Known Member Licensed User

    Ahhhm, .SO files are separated, for ARM and x86...
  17. Erel

    Erel Administrator Staff Member Licensed User

    Unpack SQLCipher.jar to see how it should look.
    peacemaker likes this.
  18. deyvitm

    deyvitm Member Licensed User

    I have put the picasso library inside InfoWindowAdapter1_GetInfoContents in google maps, when I click to show InfoWindows the image does not appear, but when I next give another image to InfoWindows if it appears, any ideas?


    GetPicasso.RunMethodJO("load", Array(url)).RunMethodJO("into", Array(ImageView1))
    ImageView1.Gravity = Gravity.FILL
  19. Erel

    Erel Administrator Staff Member Licensed User

    Please start a new thread for this question.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice