發表文章

目前顯示的是 1月 23, 2019的文章

Start a service on firebase datachange Listener?

圖片
0 I have been working on an application where i need to trigger a defined service on firebase datachange listener. I tried using IntentService but it doesn't make it to happen. I want to start a background service when there's a change occurs in firebase database. Hope you could help me out. Manifest: <service android:name=".modules.call.notifications.CallNotificationService" android:exported="false"> </service> Service: class CallNotificationService : IntentService(CallNotificationService::class.simpleName){ private var pActivity = MainBaseActivity() override fun onHandleIntent(intent: Intent?) { VFirebaseQueryManager.getUserReference(pActivity?.profile?.user_id?.toLong()!!)?.addValueEventListener(object : ValueEventListener{ ...

Banzhaf power index

圖片
For other uses, see Power index. Computer model of the Banzhaf power index from the Wolfram Demonstrations Project The Banzhaf power index , named after John F. Banzhaf III (originally invented by Lionel Penrose in 1946 and sometimes called Penrose–Banzhaf index ; also known as the Banzhaf–Coleman index after James Samuel Coleman), is a power index defined by the probability of changing an outcome of a vote where voting rights are not necessarily equally divided among the voters or shareholders. To calculate the power of a voter using the Banzhaf index, list all the winning coalitions, then count the critical voters. A critical voter is a voter who, if he changed his vote from yes to no, would cause the measure to fail. A voter's power is measured as the fraction of all swing votes that he could cast. There are some algorithms for calculating the power index, e.g., dynamic programming techniques, enumeration methods and Monte Carlo methods. [1] Contents 1 Exam...