我無法調用廣播接收對象的活動功能。有一個運行敬酒,因此執行不流存在,但本身的活動功能不被稱爲在廣播接收機不叫活動函數對象
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