我正在听" android.net.conn.CONNECTIVITY_CHANGE"在我的应用程序与广播接收器。它确实有效,但我唯一的问题是收到这个广播有很大的延迟。应用程序接收此广播需要1-2秒。难道我做错了什么? 我的清单条目 -
let fileUrl = NSURL(fileURLWithPath: "/tmp/foo.plist") // Your path here
let array = [["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"], ["One", "Two", "Three"]] // Your array of arrays here
// Save to file
(array as NSArray).writeToURL(fileUrl, atomically: true)
// Read from file
let savedArray = NSArray(contentsOfURL: fileUrl) as! [[String]]
print(savedArray)
和ConnectivityBroadcastReceiver类 -
<receiver android:name=".ConnectivityBroadcastReceiver"
android:exported="true">
<intent-filter>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE"/>
</intent-filter>
</receiver>