public class OuterClass extends Something{
private int unit = 0;
private void methodX(int num){
//Do something here
}
public static class InnerClass extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
// Need to call methodX(100) here
}
}
}
I am crating an application and it works fine. but when I am using
static OuterClass instance;
in OuterClass and access its variable through
instance.methodX(100)
from inner class it is leading to memory leak. If I remove static keyword from inner class Broadcast receiver not fired.
this is the part of my manifest file.
<receiver
android:name=".OuterClass$InnerClass"
android:enabled="true"
android:exported="true">
<intent-filter >
<action android:name="com.xyz.abc.RESULT"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</receiver>
This is working as I expected but it has some memory leak. I need to access outer class method from static inner class without a memory leak.for that I should avoid using static instance of outer class.
I am really grateful if anyone can help me to find a way to access outerClass methodX from inner class.