Click here to Skip to main content
15,116,525 members
Home / Discussions / Android
   

Android

 
AnswerRe: Firebase infinite scroll list view Load 10 items on Scrolling using firebase realtime database "Android Project" Pin
Exoskeletor13-Mar-20 2:58
MemberExoskeletor13-Mar-20 2:58 
QuestionHelp me with this simple app. Pin
All Matter25-Nov-19 9:02
MemberAll Matter25-Nov-19 9:02 
SuggestionRe: Help me with this simple app. Pin
David Crow30-Nov-19 5:33
MemberDavid Crow30-Nov-19 5:33 
AnswerRe: Help me with this simple app. Pin
Exoskeletor13-Mar-20 3:09
MemberExoskeletor13-Mar-20 3:09 
QuestionUnmanaged library exception handling Pin
wakeup4425-Nov-19 0:01
Memberwakeup4425-Nov-19 0:01 
QuestionAre BroadcastReciever and ContentObserver killed If Started From Service? Pin
Django_Untaken27-Oct-19 20:15
MemberDjango_Untaken27-Oct-19 20:15 
AnswerRe: Are BroadcastReciever and ContentObserver killed If Started From Service? Pin
Richard MacCutchan27-Oct-19 23:21
mveRichard MacCutchan27-Oct-19 23:21 
QuestionDo you believe that Kotlin will become more popular than Java? Pin
Darina Smartym15-Oct-19 23:28
MemberDarina Smartym15-Oct-19 23:28 
AnswerRe: Do you believe that Kotlin will become more popular than Java? Pin
Afzaal Ahmad Zeeshan28-Oct-19 2:02
mveAfzaal Ahmad Zeeshan28-Oct-19 2:02 
GeneralRe: Do you believe that Kotlin will become more popular than Java? Pin
The_Arcaniac2-Feb-20 0:13
MemberThe_Arcaniac2-Feb-20 0:13 
GeneralRe: Do you believe that Kotlin will become more popular than Java? Pin
Afzaal Ahmad Zeeshan2-Feb-20 8:14
mveAfzaal Ahmad Zeeshan2-Feb-20 8:14 
Questionattach .jar file to already running apk in emulator Pin
Member 1457084310-Oct-19 7:41
MemberMember 1457084310-Oct-19 7:41 
AnswerRe: attach .jar file to already running apk in emulator Pin
Richard MacCutchan10-Oct-19 23:10
mveRichard MacCutchan10-Oct-19 23:10 
GeneralRe: attach .jar file to already running apk in emulator Pin
Member 1457084311-Oct-19 1:11
MemberMember 1457084311-Oct-19 1:11 
GeneralRe: attach .jar file to already running apk in emulator Pin
Richard MacCutchan11-Oct-19 1:53
mveRichard MacCutchan11-Oct-19 1:53 
AnswerRe: attach .jar file to already running apk in emulator Pin
Leanbridge Technologies21-Nov-19 20:48
professionalLeanbridge Technologies21-Nov-19 20:48 
QuestionNullPointerException When Setting ClickListener on a RelativeLayout Pin
Django_Untaken12-Sep-19 1:52
MemberDjango_Untaken12-Sep-19 1:52 
AnswerRe: NullPointerException When Setting ClickListener on a RelativeLayout Pin
Richard MacCutchan12-Sep-19 2:40
mveRichard MacCutchan12-Sep-19 2:40 
GeneralRe: NullPointerException When Setting ClickListener on a RelativeLayout Pin
Django_Untaken12-Sep-19 2:44
MemberDjango_Untaken12-Sep-19 2:44 
GeneralRe: NullPointerException When Setting ClickListener on a RelativeLayout Pin
Richard MacCutchan12-Sep-19 3:24
mveRichard MacCutchan12-Sep-19 3:24 
SuggestionRe: NullPointerException When Setting ClickListener on a RelativeLayout Pin
David Crow12-Sep-19 10:22
MemberDavid Crow12-Sep-19 10:22 
QuestionUnRegister BroadcastReceiver Dynamically While Exiting App throws IllegalArgumentException Pin
Django_Untaken12-Sep-19 1:16
MemberDjango_Untaken12-Sep-19 1:16 
Hello there. I have this BroadcastReciever which I register and unregister dynamically, in a BASE activity. The purpose, of this receiver, is very simple. I check if HOME button is pressed? The registration of the receiver is as follows:

ActivityBase
Java
 @Override
 protected void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);

     mHomeWatcher = new HomeWatcher(this);
     mHomeWatcher.setOnHomePressedListener(new OnHomePressedListener() {
         @Override
         public void onHomePressed() {
           // my code goes here
         }
         @Override
         public void onHomeLongPressed() {
           // my code goes here
         }
     });
     mHomeWatcher.startWatch();
}

 protected void stopHomeWatcher(){
     if(mHomeWatcher != null) {
         mHomeWatcher.stopWatch();
         mHomeWatcher.setOnHomePressedListener(null);
         mHomeWatcher = null;
     }
 }

HomeWatcher
Java
public class HomeWatcher {
    public HomeWatcher(Context context) {
        mContext = context;
        mFilter = new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
    }

    public void setOnHomePressedListener(OnHomePressedListener listener) {
        mListener = listener;
        mReceiver = new InnerReceiver();
    }

    public void startWatch() {
        if (mReceiver != null) {
            mContext.registerReceiver(mReceiver, mFilter);
        }
    }

   /* EXCEPTION IN THIS FUNCTION */
    public void stopWatch() {
        if (mReceiver != null) {
            if(mContext != null)
                mContext.unregisterReceiver(mReceiver);// <<==========THIS IS WHERE I GET EXCEPTION
        }
    }

    class InnerReceiver extends BroadcastReceiver {
        final String SYSTEM_DIALOG_REASON_KEY = "reason";
        final String SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS = "globalactions";
        final String SYSTEM_DIALOG_REASON_RECENT_APPS = "recentapps";
        final String SYSTEM_DIALOG_REASON_HOME_KEY = "homekey";

        @Override
        public void onReceive(Context context, Intent intent) {
            String action = intent.getAction();
            if (action.equals(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)) {
                String reason = intent.getStringExtra(SYSTEM_DIALOG_REASON_KEY);
                if (reason != null) {
                    if(reason.trim().toLowerCase().equals("homekey")) {
                      // my code goes here
                    }
                }
            }
        }
    }
}


As you can see, I test for various NULLs. Why do I still get this weird IllegalArgumentException?
Java
java.lang.IllegalArgumentException: 
  at android.app.LoadedApk.forgetReceiverDispatcher (LoadedApk.java:1012)
  at android.app.ContextImpl.unregisterReceiver (ContextImpl.java:1360)
  at android.content.ContextWrapper.unregisterReceiver (ContextWrapper.java:608)
  at com.hiclass.earthlivecam.publiccam.earthcam.webcamhd.utils.HomeWatcher.stopWatch (HomeWatcher.java:39)
  at com.hiclass.earthlivecam.publiccam.earthcam.webcamhd.ui.activities.ActivityBase.stopHomeWatcher (ActivityBase.java:442)
  at com.hiclass.earthlivecam.publiccam.earthcam.webcamhd.ui.activities.ActivityMain.access$301 (ActivityMain.java:77)
  at com.hiclass.earthlivecam.publiccam.earthcam.webcamhd.ui.activities.ActivityMain$15.onClick (ActivityMain.java:911)
  at android.view.View.performClick (View.java:5703)
  at android.view.View$PerformClick.run (View.java:22811)
  at android.os.Handler.handleCallback (Handler.java:836)
  at android.os.Handler.dispatchMessage (Handler.java:103)
  at android.os.Looper.loop (Looper.java:203)
  at android.app.ActivityThread.main (ActivityThread.java:6297)

AnswerRe: UnRegister BroadcastReceiver Dynamically While Exiting App throws IllegalArgumentException Pin
Richard Deeming12-Sep-19 1:46
mveRichard Deeming12-Sep-19 1:46 
QuestionHow to get a email from gmail to Wordpress? Pin
Member 1456898626-Aug-19 6:42
MemberMember 1456898626-Aug-19 6:42 
AnswerRe: How to get a email from gmail to Wordpress? Pin
Richard Deeming27-Aug-19 4:09
mveRichard Deeming27-Aug-19 4:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.