如何在同一个活动中从静态内部类调用非静态方法

时间:2016-09-23 08:09:49

标签: android android-broadcastreceiver

public class ABC extends Activity{

    public void foo(int val)
    {
    }
    ...
    public static class Receive extends BroadcastReceiver{
        @Override
        public void onReceive(Context context, Intent intent) {
            ....
        }
    }
    ...
}

任何人都可以帮助我如何从接收课程的foo()拨打onReceive()

3 个答案:

答案 0 :(得分:1)

int compare(T o1, T o2);

boolean equals(Object obj); // inherited from Object class

// and a lot of concrete methods more

答案 1 :(得分:0)

public void foo(int val)移至班级Receive

答案 2 :(得分:0)

如果你不能使foo方法静态,那么你可以从接收类中删除静态。

public class Receive extends BroadcastReceiver{
    @Override
    public void onReceive(Context context, Intent intent) {

    }
}