草庐IT

message_received

全部标签

android - "IntentReceiver components are not allowed to register to receive intents"尝试确定电池电量时

我正在尝试按照http://developer.android.com/training/monitoring-device-state/battery-monitoring.html中的指南从我的应用程序中获取电池信息。这是检查电池电量的方法:publicvoidsendBatteryInfoMessage(){IntentFilteriFilter=newIntentFilter(Intent.ACTION_BATTERY_CHANGED);IntentbatteryStatus=c.registerReceiver(null,iFilter);intstatus=batteryS

android - SMS_RECEIVED 不能在 Ice Cream Sandwich 上工作?

我正在尝试使用android.provider.Telephony.SMS_RECEIVED来捕获传入的短信。我构建了一个简单的应用程序,可以在2.x上运行,但是当我在4.0模拟器或设备上尝试它时,它不起作用。有什么想法吗?list:MyFirstApp.javapublicclassMyFirstAppextendsBroadcastReceiver{privatestaticfinalStringSMS_RECEIVED="android.provider.Telephony.SMS_RECEIVED";privatestaticfinalStringTAG="MyFirstApp

android - "Error receiving broadcast Intent {....}"是什么意思?

我的应用包含一个通过广播接收位置的服务,还有一个注册这些相同广播的Activity。间歇性地,显然仅在某些设备上,Activity会因此而爆发:classjava.lang.RuntimeExceptionMsg:ErrorreceivingbroadcastIntent{act=com.company.app.ACTION_LOCATION_CHANGEDflg=0x10(hasextras)}incom.company.app.library.activity.MyActivity$LocationReceiver@40f45bb8我无法使用调试器查看应用程序的状态,因为我无法重现

android - 奇怪的 "Receiver not registered"异常

在onResume()中我会这样做:registerReceiver(timeTickReceiver,newIntentFilter(Intent.ACTION_TIME_TICK));在onPause()中:unregisterReceiver(timeTickReceiver);我在Android开发者控制台中看到“java.lang.IllegalArgumentException:Receivernotregistered”报告(只有2份报告,我的应用有数千名用户)。异常由unregisterReceiver()触发。会发生什么?只是用try-catch包围它,我觉得不是很有

android - 错误广播 Intent 回调 : result=CANCELLED forIntent { act=com. google.android.c2dm.intent.RECEIVE pkg=com.flagg327.guicomaipu(有附加功能)}

我从AndroidStudio的Android监视器收到了该错误。当我通过GCM在真实设备中发送推送通知并且应用程序尚未启动或已被强制停止时,会出现此错误。昨天一切正常,今天根本不工作(仅当应用程序在后台或前台运行时才有效)。我认为这可能是一个AndroidManifest错误,但是我已经厌倦了寻找问题并且找不到任何东西。list......TokenRefreshListenerService.java注册“token”每天都会更新。这是因为,每个使用GCM的Android应用程序都必须有一个InstanceIDListenerService来管理这些更新。publicclassTo

android - Google Cloud Messaging (GCM) 使用哪个端口和协议(protocol)?

GoogleCloudMessaging(GCM)使用哪个端口和协议(protocol)?我们有时会遇到消息无法通过的情况,并且注意到这取决于我们所在的网络。 最佳答案 设备通过端口5228-5230访问GCM服务器。Note:IfyourorganizationhasafirewallthatrestrictsthetraffictoorfromtheInternet,you'llneedtoconfigureittoallowconnectivitywithGCM.Theportstoopenare:5228,5229,and5

与 Firebase 相关的 Google Play 服务更新后,Android Google Cloud Messaging (GCM) token 生成崩溃

我的Android应用程序今天在为GoogleCloudMessaging(GCM)生成token时开始崩溃。这发生在多种设备和Android版本上。我认为这可能与Google昨天在GoogleIO上宣布的新Firebase功能有关。当这种情况开始发生时,我没有处理与GCM相关的代码,所以这是出乎意料的。如果我从Android系统设置中卸载GooglePlay服务更新,该应用程序将不再崩溃。一旦我重新安装最新版本,应用程序每次都会再次崩溃。FATALEXCEPTION:IntentService[MyGCMRegistrationIntentService]Process:,PID:2

android - NullPointerException : println needs a message in android

在我的媒体播放器中,我从sdcard播放一首歌曲。它显示错误为NullPointerException:println需要在android中显示消息e。我尝试了很长时间,但我不知道原因。请帮助我。代码:try{mediaPlayer=newMediaPlayer();mediaPlayer.setDataSource("/sdcard/t1.mp3");seek.setMax(mediaPlayer.getDuration());mediaPlayer.prepare();mediaPlayer.start();mediaPlayer.setOnCompletionListener(t

android - 更新 GUI : Runnables vs Messages

要从其他线程更新GUI,主要有两种方法:将java.lang.Runnable与以下任一方法一起使用:Activity.runOnUiThread(Runnable)View.post(Runnable)View.postDelayed(Runnable,long)Handler.post(Runnable)使用android.os.Message:Handler.sendMessage(Message)/Handler.handleMessage(Message)您也可以使用AsyncTask,但我的问题更侧重于更新一个非常简单的组件的用例。让我们看看如何使用这两种方法来完成:使用R

c++ - Boost.Asio : The difference between async_read and async_receive

async_read和有什么区别?和async_receive? 最佳答案 async_receive是一个仅接收到缓冲区的函数,但可能无法接收您要求的数量。(它会相等或更少,永远不会更多。)但是,async_read将始终收到您要求的金额,如其所述:Thisfunctionisusedtoasynchronouslyreadacertainnumberofbytesofdatafromastream.Thefunctioncallalwaysreturnsimmediately.Theasynchronousoperationwi