Calling a function there is located in a Service

0

I have made an API call to the website https://owlbot.info/, where i recieve som infomation. Right now it's running in my MainActivity(It's called ListActivity), but I want it to be called from my service, but when I tried to call it from my service, my app craches. I dont know if it's because I'm calling it wrong? But what I'm trying to do it moving the funciton searchWord() and parseData() over to the service, and use these function from my MainActivity. The SearcheWord(), is called from my button click right now.

MainActivity.java

...
    String url, input, finalUrl;
    JSONObject entry;
    String definition;
    String type;
    String example;
    Button searchBtn;
    TextInputEditText editSearch;
    String urlImage;
    WordLeanerService WLService;
    ServiceConnection WLConn;
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        startService(new Intent(ListActivity.this,WordLeanerService.class).putExtra("inputExtra", s1));
        setupConnectionToWLservice();
        editSearch = findViewById(R.id.edit_search);
        url = getString(R.string.url_dictionary);
        searchBtn = findViewById(R.id.search_button);

        searchBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //Saving user's input in search field
                input = String.valueOf(editSearch.getText());

                //Checking if input is valid (not empty and only alphabet characters)
                if (!input.equals("") && (input.matches("[a-zA-Z]+"))) {
                    //Sending input to request
                    //WLService.getWord(input); //I tried this
                    searchWord(input);

                } else {
                    Toast.makeText(getApplicationContext(), getString(R.string.input_invalid_message_toast), Toast.LENGTH_LONG).show();
                }
            }
        });
    }
    private void searchWord(String word) {
        //Adding user's input to the url that will be used in the request
        finalUrl = url + word;
        Toast.makeText(this, finalUrl, Toast.LENGTH_SHORT).show();
        final OwlAPI jsonParserVolley = new OwlAPI(this);
        jsonParserVolley.requestData(finalUrl, new VollyCallback() {
                    @Override
                    public void getResponse(JSONObject response) {
                        parseData(response);
                    }
                }
        );
    }
    private void parseData(JSONObject response) {
        try {
            String word = response.getString("word");
            JSONArray definitions = response.getJSONArray("definitions");
            for (int i = 0; i < definitions.length(); i++) {
                entry = definitions.getJSONObject(i);
                definition = String.valueOf(entry.get("definition"));
                type = entry.getString("type");
                example = entry.getString("example");
                urlImage = String.valueOf(entry.get("image_url"));
            }
            String pronunciation = response.getString("pronunciation");
            Context cotext1 = getApplicationContext();

            Toast.makeText(cotext1, "URL: "+urlImage, Toast.LENGTH_SHORT).show();
            Toast.makeText(cotext1, word, Toast.LENGTH_SHORT).show();
            Toast.makeText(cotext1, definition, Toast.LENGTH_SHORT).show();
            if(!pronunciation.equals("null")){
                Toast.makeText(cotext1, "/" + pronunciation + "/", Toast.LENGTH_SHORT).show();
            }

        } catch (JSONException e) {
            e.printStackTrace();
        }
    }
    private void setupConnectionToWLservice(){
        WLConn = new ServiceConnection() {
            public void onServiceConnected(ComponentName className, IBinder service) {
                bindService(new Intent(ListActivity.this,WordLeanerService.class),WLConn, Context.BIND_AUTO_CREATE);
                //ref: http://developer.android.com/reference/android/app/Service.html
                WLService = ((WordLeanerService.ServiceBinder)service).getService();
                //TODO: probably a good place to update UI after data loading
            }

            public void onServiceDisconnected(ComponentName className) {
                //ref: http://developer.android.com/reference/android/app/Service.html
                WLService = null;
            }
        };
    }
...

What is tried was moving all the code over to the service, in a function called public void getWord(String w) {....}, and then in the MainActivity, in the OnClickListener i called this WLService.getWord(input);, but then the app crashes.

Info about service: When the app starts the service is run, i have a array of words, where the service has to output a notification with a random word from the list every 60 sec, thats why i have the Handler, could this be a problem because i have this kind of "loop", in my service? if so, could it be done in another way then?

WordLeanerService.java

    private final IBinder binder = new ServiceBinder();
    public static final String CHANNEL_ID = "ForegroundServiceChannel";
    //extend the Binder class - we will return and instance of this in the onBind()
    public class ServiceBinder extends Binder {
        //return ref to service (or at least an interface) that activity can call public methods on
        WordLeanerService getService() {
            return WordLeanerService.this;
        }
    }
    public WordLeanerService() {
    }

    @Override
    public IBinder onBind(Intent intent) {
        return binder;
    }
    @Override
    public int onStartCommand(final Intent intent, int flags, int startId) {
        final Notification notification = new NotificationCompat.Builder(this, CHANNEL_ID)
                .build();
        startForeground(1, notification);
        final Handler handler = new Handler();
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                notificationGenerator(intent);
                handler.postDelayed(this, 60000);
            }
        }, 60000);
        return START_NOT_STICKY;
    }
    public void notificationGenerator(Intent intent){
        String input[] = intent.getStringArrayExtra("inputExtra");
        final int random = new Random().nextInt((input.length - 0) + 1) + 0;
        createNotificationChannel();
        Intent notificationIntent = new Intent(this, ListActivity.class);
        PendingIntent pendingIntent = PendingIntent.getActivity(this,
                0, notificationIntent, 0);
        final Notification notification = new NotificationCompat.Builder(this, CHANNEL_ID)
                .setContentTitle("Learn this word:")
                .setContentText(input[random])
                .setSmallIcon(R.mipmap.ic_launcher_foreground)
                .setContentIntent(pendingIntent)
                .build();
        startForeground(1, notification);
    }
    private void createNotificationChannel() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            NotificationChannel serviceChannel = new NotificationChannel(
                    CHANNEL_ID,
                    "Foreground Service Channel",
                    NotificationManager.IMPORTANCE_DEFAULT
            );
            NotificationManager manager = getSystemService(NotificationManager.class);
            manager.createNotificationChannel(serviceChannel);
        }
    }
    public void getWord(String w) {
        //Code should go here?
    }

To sum up the question:

How can i call a function, located in WordLeanerService.java, from my mainactivity OnClickListener?

EDIT LOGCAT OUTPUT WHEN TRYING TO CALL FUNCTION FROM SERVICE

2020-03-27 11:09:08.565 2052-2404/? I/ActivityTaskManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.example.word_learner_app/.ListActivity bnds=[237,1264][439,1517]} from uid 10090
2020-03-27 11:09:08.577 1801-3746/? W/audio_hw_generic: Not supplying enough data to HAL, expected position 106129573 , only wrote 106129499
2020-03-27 11:09:08.612 2052-2052/? W/ActivityManager: Unable to start service Intent { act=android.service.appprediction.AppPredictionService cmp=com.google.android.as/com.google.android.apps.miphone.aiai.app.AiAiPredictionService } U=0: not found
2020-03-27 11:09:08.613 2052-2052/? W/RemoteAppPredictionService: could not bind to Intent { act=android.service.appprediction.AppPredictionService cmp=com.google.android.as/com.google.android.apps.miphone.aiai.app.AiAiPredictionService } using flags 67108865
2020-03-27 11:09:08.667 2052-4947/? W/InputReader: Device has associated, but no associated display id.
2020-03-27 11:09:08.667 2052-4947/? I/chatty: uid=1000(system) Binder:2052_20 identical 8 lines
2020-03-27 11:09:08.667 2052-4947/? W/InputReader: Device has associated, but no associated display id.
2020-03-27 11:09:08.733 1818-2577/? E/GnssHAL_GnssInterface: gnssSvStatusCb: a: input svInfo.flags is 8
2020-03-27 11:09:08.733 1818-2577/? E/GnssHAL_GnssInterface: gnssSvStatusCb: b: input svInfo.flags is 8
2020-03-27 11:09:08.755 2822-2835/? I/s.nexuslaunche: NativeAlloc concurrent copying GC freed 27892(1216KB) AllocSpace objects, 3(204KB) LOS objects, 49% free, 4801KB/9602KB, paused 671us total 160.088ms
2020-03-27 11:09:08.765 2052-2083/? W/ActivityManager: Slow operation: 89ms so far, now at startProcess: returned from zygote!
2020-03-27 11:09:08.765 2052-2083/? W/ActivityManager: Slow operation: 90ms so far, now at startProcess: done updating battery stats
2020-03-27 11:09:08.765 2052-2083/? W/ActivityManager: Slow operation: 90ms so far, now at startProcess: building log message
2020-03-27 11:09:08.765 2052-2083/? I/ActivityManager: Start proc 26261:com.example.word_learner_app/u0a146 for activity {com.example.word_learner_app/com.example.word_learner_app.ListActivity}
2020-03-27 11:09:08.765 2052-2083/? W/ActivityManager: Slow operation: 90ms so far, now at startProcess: starting to update pids map
2020-03-27 11:09:08.766 2052-2083/? W/ActivityManager: Slow operation: 90ms so far, now at startProcess: done updating pids map
2020-03-27 11:09:08.772 26261-26261/? I/ord_learner_ap: Not late-enabling -Xcheck:jni (already on)
2020-03-27 11:09:08.811 26261-26261/? E/ord_learner_ap: Unknown bits set in runtime_flags: 0x8000
2020-03-27 11:09:08.812 26261-26261/? W/ord_learner_ap: Unexpected CPU variant for X86 using defaults: x86
2020-03-27 11:09:08.897 2052-2404/? W/InputReader: Device has associated, but no associated display id.
2020-03-27 11:09:08.897 2052-2404/? I/chatty: uid=1000(system) Binder:2052_7 identical 8 lines
2020-03-27 11:09:08.897 2052-2404/? W/InputReader: Device has associated, but no associated display id.
2020-03-27 11:09:08.900 3396-3396/? W/adbd: timeout expired while flushing socket, closing
2020-03-27 11:09:08.905 2052-2404/? W/InputReader: Device has associated, but no associated display id.
2020-03-27 11:09:08.963 2052-2404/? W/ActivityManager: Slow operation: 70ms so far, now at attachApplicationLocked: after mServices.attachApplicationLocked
2020-03-27 11:09:08.956 2052-2404/? I/chatty: uid=1000(system) Binder:2052_7 identical 18 lines
2020-03-27 11:09:08.956 2052-2404/? W/InputReader: Device has associated, but no associated display id.
2020-03-27 11:09:08.979 2052-2077/? W/InputReader: Device has associated, but no associated display id.
2020-03-27 11:09:08.979 2052-2077/? I/chatty: uid=1000(system) android.anim identical 8 lines
2020-03-27 11:09:08.979 2052-2077/? W/InputReader: Device has associated, but no associated display id.
2020-03-27 11:09:09.088 1820-1863/? W/EmuHWC2: validate: layer 3132 CompositionType 1, fallback
2020-03-27 11:09:09.233 1820-1863/? I/chatty: uid=1000(system) HwBinder:1820_1 identical 5 lines
2020-03-27 11:09:09.268 1820-1863/? W/EmuHWC2: validate: layer 3132 CompositionType 1, fallback
2020-03-27 11:09:09.288 1820-1863/? W/EmuHWC2: validate: layer 3132 CompositionType 1, fallback
2020-03-27 11:09:09.313 1820-1863/? W/EmuHWC2: validate: layer 3132 CompositionType 1, fallback
2020-03-27 11:09:09.329 1820-1863/? W/EmuHWC2: validate: layer 3132 CompositionType 1, fallback
2020-03-27 11:09:09.348 1820-1863/? W/EmuHWC2: validate: layer 3132 CompositionType 1, fallback
2020-03-27 11:09:09.371 1820-1863/? W/EmuHWC2: validate: layer 3132 CompositionType 1, fallback
2020-03-27 11:09:09.391 1820-1863/? W/EmuHWC2: validate: layer 3132 CompositionType 1, fallback
2020-03-27 11:09:09.411 1820-1863/? W/EmuHWC2: validate: layer 3132 CompositionType 1, fallback
2020-03-27 11:09:09.458 1841-2628/? E/SurfaceFlinger: ro.sf.lcd_density must be defined as a build property
2020-03-27 11:09:09.463 1841-1925/? E/SurfaceFlinger: ro.sf.lcd_density must be defined as a build property
2020-03-27 11:09:09.456 26261-26261/com.example.word_learner_app W/RenderThread: type=1400 audit(0.0:4822): avc: denied { write } for name="property_service" dev="tmpfs" ino=7372 scontext=u:r:untrusted_app:s0:c146,c256,c512,c768 tcontext=u:object_r:property_socket:s0 tclass=sock_file permissive=0
2020-03-27 11:09:09.467 26261-26296/com.example.word_learner_app W/libc: Unable to set property "qemu.gles" to "1": connection failed; errno=13 (Permission denied)
2020-03-27 11:09:09.472 1841-1841/? E/Layer: [Surface(name=AppWindowToken{99d896f token=Token{7fec44e ActivityRecord{28cb349 u0 com.google.android.apps.nexuslauncher/.NexusLauncherActivity t5}}})/@0xa31bd2f - animation-leash#0] No local sync point found
2020-03-27 11:09:09.472 1841-1841/? E/Layer: [Surface(name=AppWindowToken{99d896f token=Token{7fec44e ActivityRecord{28cb349 u0 com.google.android.apps.nexuslauncher/.NexusLauncherActivity t5}}})/@0xa31bd2f - animation-leash#0] No local sync point found
2020-03-27 11:09:09.472 1841-1841/? E/Layer: [Surface(name=AppWindowToken{e396fed token=Token{b245e04 ActivityRecord{d026a17 u0 com.example.word_learner_app/.ListActivity t431}}})/@0x368d946 - animation-leash#0] No local sync point found
2020-03-27 11:09:09.472 1841-1841/? E/Layer: [Surface(name=AppWindowToken{e396fed token=Token{b245e04 ActivityRecord{d026a17 u0 com.example.word_learner_app/.ListActivity t431}}})/@0x368d946 - animation-leash#0] No local sync point found
2020-03-27 11:09:09.735 1818-2577/? E/GnssHAL_GnssInterface: gnssSvStatusCb: a: input svInfo.flags is 8
2020-03-27 11:09:09.735 1818-2577/? E/GnssHAL_GnssInterface: gnssSvStatusCb: b: input svInfo.flags is 8
2020-03-27 11:09:09.773 2052-2083/? I/ActivityManager: Start proc 26298:com.example.word_learner_app:WordLeanerService/u0a146 for service {com.example.word_learner_app/com.example.word_learner_app.WordLeanerService}
2020-03-27 11:09:09.773 26298-26298/? I/rdLeanerServic: Not late-enabling -Xcheck:jni (already on)
2020-03-27 11:09:09.811 26298-26298/? E/rdLeanerServic: Unknown bits set in runtime_flags: 0x8000
2020-03-27 11:09:09.812 26298-26298/? W/rdLeanerServic: Unexpected CPU variant for X86 using defaults: x86
2020-03-27 11:09:09.944 26261-26261/com.example.word_learner_app W/ord_learner_ap: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (greylist, reflection, allowed)
2020-03-27 11:09:09.945 26261-26261/com.example.word_learner_app W/ord_learner_ap: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (greylist, reflection, allowed)
2020-03-27 11:09:10.279 2052-2082/? W/ActivityManager: Error showing notification for service
    java.lang.RuntimeException: invalid channel for service notification: Notification(channel=ForegroundServiceChannel pri=0 contentView=null vibrate=null sound=null defaults=0x0 flags=0x40 color=0x00000000 vis=PRIVATE)
        at com.android.server.am.ServiceRecord$1.run(ServiceRecord.java:877)
        at android.os.Handler.handleCallback(Handler.java:883)
        at android.os.Handler.dispatchMessage(Handler.java:100)
        at android.os.Looper.loop(Looper.java:214)
        at android.os.HandlerThread.run(HandlerThread.java:67)
        at com.android.server.ServiceThread.run(ServiceThread.java:44)
2020-03-27 11:09:10.284 26298-26298/com.example.word_learner_app:WordLeanerService E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.word_learner_app:WordLeanerService, PID: 26298
    android.app.RemoteServiceException: Bad notification for startForeground: java.lang.RuntimeException: invalid channel for service notification: Notification(channel=ForegroundServiceChannel pri=0 contentView=null vibrate=null sound=null defaults=0x0 flags=0x40 color=0x00000000 vis=PRIVATE)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1945)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7356)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
2020-03-27 11:09:10.307 2052-26333/? I/DropBoxManagerService: add tag=data_app_crash isTagEnabled=true flags=0x2
2020-03-27 11:09:10.334 2052-2074/? I/ActivityManager: Showing crash dialog for package com.example.word_learner_app u0
2020-03-27 11:09:10.339 2052-2082/? W/BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.DROPBOX_ENTRY_ADDED flg=0x10 (has extras) } to com.google.android.gms/.stats.service.DropBoxEntryAddedReceiver
2020-03-27 11:09:10.341 2052-2082/? W/BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.DROPBOX_ENTRY_ADDED flg=0x10 (has extras) } to com.google.android.gms/.chimera.GmsIntentOperationService$PersistentTrustedReceiver
2020-03-27 11:09:10.412 26261-26261/com.example.word_learner_app W/ord_learner_ap: Accessing hidden method Landroid/graphics/FontFamily;-><init>()V (greylist, reflection, allowed)
2020-03-27 11:09:10.412 26261-26261/com.example.word_learner_app W/ord_learner_ap: Accessing hidden method Landroid/graphics/FontFamily;->addFontFromAssetManager(Landroid/content/res/AssetManager;Ljava/lang/String;IZIII[Landroid/graphics/fonts/FontVariationAxis;)Z (greylist, reflection, allowed)
2020-03-27 11:09:10.413 26261-26261/com.example.word_learner_app W/ord_learner_ap: Accessing hidden method Landroid/graphics/FontFamily;->addFontFromBuffer(Ljava/nio/ByteBuffer;I[Landroid/graphics/fonts/FontVariationAxis;II)Z (greylist, reflection, allowed)
2020-03-27 11:09:10.413 26261-26261/com.example.word_learner_app W/ord_learner_ap: Accessing hidden method Landroid/graphics/FontFamily;->freeze()Z (greylist, reflection, allowed)
2020-03-27 11:09:10.413 26261-26261/com.example.word_learner_app W/ord_learner_ap: Accessing hidden method Landroid/graphics/FontFamily;->abortCreation()V (greylist, reflection, allowed)
2020-03-27 11:09:10.413 26261-26261/com.example.word_learner_app W/ord_learner_ap: Accessing hidden method Landroid/graphics/Typeface;->createFromFamiliesWithDefault([Landroid/graphics/FontFamily;Ljava/lang/String;II)Landroid/graphics/Typeface; (greylist, reflection, allowed)
2020-03-27 11:09:10.427 2052-2074/? W/Looper: Slow dispatch took 108ms android.ui h=com.android.server.am.ActivityManagerService$UiHandler c=null m=1
2020-03-27 11:09:10.466 2052-8267/? W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
2020-03-27 11:09:10.715 2052-2074/? W/Looper: Slow dispatch took 277ms android.ui h=android.view.Choreographer$FrameHandler c=android.view.Choreographer$FrameDisplayEventReceiver@3c5c9f7 m=0
2020-03-27 11:09:10.727 2052-2074/? W/Looper: Slow delivery took 300ms android.ui h=com.android.server.wm.DisplayPolicy$PolicyHandler c=com.android.server.wm.-$$Lambda$DisplayPolicy$qQY9m_Itua9TDy-Nk3zzDxvjEwE@e37f848 m=0
2020-03-27 11:09:10.733 1818-2577/? E/GnssHAL_GnssInterface: gnssSvStatusCb: a: input svInfo.flags is 8
2020-03-27 11:09:10.733 1818-2577/? E/GnssHAL_GnssInterface: gnssSvStatusCb: b: input svInfo.flags is 8
2020-03-27 11:09:10.734 2052-2074/? W/Looper: Drained
2020-03-27 11:09:10.760 26261-26294/com.example.word_learner_app W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
2020-03-27 11:09:10.865 2052-2074/? W/Looper: Slow dispatch took 113ms android.ui h=android.view.Choreographer$FrameHandler c=android.view.Choreographer$FrameDisplayEventReceiver@3c5c9f7 m=0
2020-03-27 11:09:10.897 1679-1679/? I/hwservicemanager: getTransport: Cannot find entry android.hardware.graphics.mapper@3.0::IMapper/default in either framework or device manifest.
2020-03-27 11:09:10.898 26261-26294/com.example.word_learner_app W/Gralloc3: mapper 3.x is not supported
2020-03-27 11:09:10.976 26261-26274/com.example.word_learner_app I/ord_learner_ap: Background young concurrent copying GC freed 9426(1311KB) AllocSpace objects, 6(120KB) LOS objects, 78% free, 1655KB/7799KB, paused 5.291ms total 162.643ms
2020-03-27 11:09:11.037 2052-2064/? I/system_server: Background concurrent copying GC freed 90420(4791KB) AllocSpace objects, 35(960KB) LOS objects, 18% free, 26MB/32MB, paused 782us total 707.875ms
2020-03-27 11:09:11.409 2052-2081/? I/ActivityTaskManager: Displayed com.example.word_learner_app/.ListActivity: +2s842ms
2020-03-27 11:09:11.494 26261-26261/com.example.word_learner_app I/Choreographer: Skipped 50 frames!  The application may be doing too much work on its main thread.
2020-03-27 11:09:11.612 2052-4924/? I/ActivityManager: Killing 26298:com.example.word_learner_app:WordLeanerService/u0a146 (adj 500): crash
2020-03-27 11:09:11.653 9048-25161/? I/PBSessionCacheImpl: Deleted sessionId[359450421015] from persistence.
2020-03-27 11:09:11.683 9048-9115/? W/SearchServiceCore: Abort, client detached.
2020-03-27 11:09:11.697 1841-1841/? W/SurfaceFlinger: couldn't log to binary event log: overflow.
2020-03-27 11:09:11.699 2052-4924/? E/InputDispatcher: Window handle Window{45751ad u0 Application Error: com.example.word_learner_app} has no registered input channel
2020-03-27 11:09:11.713 1780-1780/? I/Zygote: Process 26298 exited due to signal 9 (Killed)
2020-03-27 11:09:11.734 1818-2577/? E/GnssHAL_GnssInterface: gnssSvStatusCb: a: input svInfo.flags is 8
2020-03-27 11:09:11.734 1818-2577/? E/GnssHAL_GnssInterface: gnssSvStatusCb: b: input svInfo.flags is 8
2020-03-27 11:09:11.752 2052-2084/? I/libprocessgroup: Successfully killed process cgroup uid 10146 pid 26298 in 139ms
2020-03-27 11:09:12.586 26261-26261/com.example.word_learner_app I/AssistStructure: Flattened final assist data: 1904 bytes, containing 1 windows, 11 views
2020-03-27 11:09:12.599 11989-11989/? W/ljg: Pending fill request while another request in the same session was triggered. [CONTEXT service_id=177 ]
2020-03-27 11:09:12.628 11341-11341/? I/KeyboardViewUtil: systemKeyboardHeightRatio:1.000000; userKeyboardHeightRatio:1.000000.
2020-03-27 11:09:12.627 11989-11989/? E/ActivityThread: Service com.google.android.gms.autofill.service.AutofillService has leaked IntentReceiver com.google.android.gms.autofill.smsretriever.TracingSmsBroadcastReceiver@aa4f597 that was originally registered here. Are you missing a call to unregisterReceiver()?
    android.app.IntentReceiverLeaked: Service com.google.android.gms.autofill.service.AutofillService has leaked IntentReceiver com.google.android.gms.autofill.smsretriever.TracingSmsBroadcastReceiver@aa4f597 that was originally registered here. Are you missing a call to unregisterReceiver()?
        at android.app.LoadedApk$ReceiverDispatcher.<init>(LoadedApk.java:1588)
        at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:1368)
        at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1515)
        at android.app.ContextImpl.registerReceiver(ContextImpl.java:1488)
        at android.app.ContextImpl.registerReceiver(ContextImpl.java:1476)
        at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:627)
        at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:627)
        at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:627)
        at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:627)
        at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:627)
        at lnz.<init>(:com.google.android.gms@200616040@20.06.16 (120700-296104215):5)
        at lmq.<init>(:com.google.android.gms@200616040@20.06.16 (120700-296104215):1)
        at lah.a(:com.google.android.gms@200616040@20.06.16 (120700-296104215):9)
        at cadm.a(:com.google.android.gms@200616040@20.06.16 (120700-296104215):5)
        at lap.a(:com.google.android.gms@200616040@20.06.16 (120700-296104215):2)
        at cadm.a(:com.google.android.gms@200616040@20.06.16 (120700-296104215):5)
        at kys.b(:com.google.android.gms@200616040@20.06.16 (120700-296104215):0)
        at ljg.onFillRequest(:com.google.android.gms@200616040@20.06.16 (120700-296104215):73)
        at android.service.autofill.-$$Lambda$I0gCKFrBTO70VZfSZTq2fj-wyG8.accept(Unknown Source:8)
        at com.android.internal.util.function.pooled.PooledLambdaImpl.doInvoke(PooledLambdaImpl.java:300)
        at com.android.internal.util.function.pooled.PooledLambdaImpl.invoke(PooledLambdaImpl.java:195)
        at com.android.internal.util.function.pooled.OmniFunction.run(OmniFunction.java:86)
        at android.os.Handler.handleCallback(Handler.java:883)
        at android.os.Handler.dispatchMessage(Handler.java:100)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7356)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
2020-03-27 11:09:12.629 11341-11341/? I/AndroidIME: LatinIme.onActivate() : EditorInfo = Package = com.example.word_learner_app : Type = Text : Learning = Disable : Suggestion = Show : AutoCorrection = Disable : Microphone = Show : NoPersonalizedLearning = Disable
2020-03-27 11:09:12.646 11341-11341/? I/Conv2QueryExtension: Current locale: da, config allows these locales: de,en,es,fr,it,ms,pt,ta
2020-03-27 11:09:12.647 11341-11341/? W/Conv2QueryExtension: Conv2Query not enabled due to current locale [da] not in whitelist [de,en,es,fr,it,ms,pt,ta].
2020-03-27 11:09:12.647 11341-11341/? I/Conv2QueryExtension: onActivate() : Disabled by unsupported locale
2020-03-27 11:09:12.737 1818-2577/? E/GnssHAL_GnssInterface: gnssSvStatusCb: a: input svInfo.flags is 8
2020-03-27 11:09:12.737 1818-2577/? E/GnssHAL_GnssInterface: gnssSvStatusCb: b: input svInfo.flags is 8
2020-03-27 11:09:13.397 11341-11496/? I/native: input-context-store.cc:172 Ignoring stale client request for FetchSuggestions
2020-03-27 11:09:13.733 1818-2577/? E/GnssHAL_GnssInterface: gnssSvStatusCb: a: input svInfo.flags is 8
2020-03-27 11:09:13.733 1818-2577/? E/GnssHAL_GnssInterface: gnssSvStatusCb: b: input svInfo.flags is 8
2020-03-27 11:09:14.715 26261-26261/com.example.word_learner_app E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.word_learner_app, PID: 26261
    java.lang.NullPointerException: Attempt to invoke virtual method 'void com.example.word_learner_app.WordLeanerService.getWord(java.lang.String)' on a null object reference
        at com.example.word_learner_app.ListActivity$1.onClick(ListActivity.java:77)
        at android.view.View.performClick(View.java:7125)
        at android.view.View.performClickInternal(View.java:7102)
        at android.view.View.access$3500(View.java:801)
        at android.view.View$PerformClick.run(View.java:27336)
        at android.os.Handler.handleCallback(Handler.java:883)
        at android.os.Handler.dispatchMessage(Handler.java:100)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7356)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
2020-03-27 11:09:14.722 2052-3006/? W/ActivityManager: Process com.example.word_learner_app has crashed too many times: killing!
2020-03-27 11:09:14.722 2052-3006/? W/ActivityTaskManager:   Force finishing activity com.example.word_learner_app/.ListActivity
2020-03-27 11:09:14.727 2052-26349/? I/DropBoxManagerService: add tag=data_app_crash isTagEnabled=true flags=0x2
java
android
asked on Stack Overflow Mar 27, 2020 by Mads • edited Mar 27, 2020 by Mads

1 Answer

0

Updated

Try Replacing

 bindService(new Intent(ListActivity.this,WordLeanerService.class),WLConn, Context.BIND_AUTO_CREATE);

With

 bindService(new Intent(MainActivity.this,WordLeanerService.class),WLConn,Context.BIND_AUTO_CREATE);
answered on Stack Overflow Mar 27, 2020 by Usman Zafer • edited Mar 27, 2020 by Usman Zafer

User contributions licensed under CC BY-SA 3.0