Tag: android broadcastreceiver

在Kotlin的BroadcastReceiver不起作用

使用本手册http://www.techotopia.com/index.php/Kotlin_Android_Broadcast_Intents_and_Broadcast_Receivers#.EF.BB.BFSummary我已经在Kotlin中实现了BroadcastReceiver,所以我期望在重新启动后,应用程序将启动,但它不会。 请帮忙。 谢谢! 广播接收器 class BroadcastReceiverOnBootComplete : BroadcastReceiver() { override fun onReceive(context: Context, intent: Intent) { if (intent.action.equals(Intent.ACTION_BOOT_COMPLETED, ignoreCase = true)) { val message = “Broadcast intent detected ” + intent.action Toast.makeText(context, message, Toast.LENGTH_LONG).show() } } } 清单文件 MainActivity与BroadcastReceiver class MainActivity : SimpleActivity(), RefreshRecyclerViewListener { private var launchers = ArrayList() private var mStoredPrimaryColor = 0 […]

广播接收器onReceive()不被调用

广播接收机 mBroadcastReceiver = object : BroadcastReceiver() { override fun onReceive(context: Context, intent: Intent) { Log.i(TAG,"contact list populate broadcast") var action = intent.action Log.v("Action is ",action) when (action) { GetContactListFromServer -> { println("Get contact list") } } } } val filter = IntentFilter(GetContactListFromServer) this.registerReceiver(mBroadcastReceiver, filter) 这是我如何发送广播 val i = Intent(ContactListActivity.Obz.GetContactListFromServer) i.`package` = mApplicationContext?.getPackageName() mApplicationContext?.sendBroadcast(i) 此代码工作正常,直到昨晚。 我无法调试出了什么问题?

如何在android中以编程方式捕获取消下载事件

当文件开始下载时,我正在显示进度条,如果它已完成,我更改了成功下载图标的进度栏。 它完美的作品,但我面临的问题是,如果有人点击通知托盘中的取消按钮,它不会发送广播,我已经创建接收广播,如果文件被下载。 我正在使用DownloadManager下载文件,而且我们知道在棉花糖,我们得到一个选项来下载文件,但我怎样才能捕获这个取消按钮的事件。 这是我的代码: <receiver android:name=".adapters.VideoListAdapter$VideoDownloadedReceiver"> <intent-filter> <action android:name="android.intent.action.DOWNLOAD_COMPLETE" /> <action android:name="android.intent.action.DOWNLOAD_CANCEL" /> </intent-filter> </receiver> public static class VideoDownloadedReceiver extends BroadcastReceiver implements AsyncResponse { @Override public void onReceive(Context context, Intent intent) { //perform event //works well if files gets completed but not if download gets cancel } }

Android:活动重叠另一个应用程序

我需要一些帮助来指导我在一个项目中,我需要我的应用程序识别另一个应用程序何时开始,然后我的活动出现。 我研究了服务,intentservice和broadcastreceiver。 但我不知道如何执行我的想法。 你们可以推荐我一些职位,书籍,教程吗? PS:我熟悉Java和Kotlin