我无法调用广播接收对象的活动功能。有一个运行敬酒,因此执行不流存在,但本身的活动功能不被称为在广播接收机不叫活动函数对象
protected void onCreate()
{
...
...
this.registerReceiver(receiver, new IntentFilter("ACTION"));
}
BroadcastReceiver receiver = new BroadcastReceiver() {
Toast.makeText(MainActivity.this, "Printed", Toast.LENGTH_LONG).show(); // This runs
FunctionA(); // <-- This function is not called
};
public void FunctionA()
{
... // Function holds view objects
}
我环顾四周,试图像这样的接收对象的内部没有任何的运气
BroadcastReceiver receiver = new BroadcastReceiver() {
Toast.makeText(MainActivity.this, "Printed", Toast.LENGTH_LONG).show(); //<--- This runs fine
MainActivity.this.runOnUiThread(new Runnable() {
@Override
public void run() {
FunctionA(); // <-- Function still is not called
}
});
}
问题是为什么不调用函数?有没有办法在该广播接收器对象中调用该函数?
您确切地说,确定“函数”没有被调用? FunctionA()'确实*做了什么? – CommonsWare
该函数负责改变UI上的视图。我甚至有Logs中没有打印在Logcat中的函数。 – Czar