My app includes a service which receives locations via broadcasts, and there is also an activity that registers for those same broadcasts. Intermittently, and apparently only on some devices, the activity blows up with this:
class java.lang.RuntimeException
Msg: Error receiving broadcast Intent { act=com.company.app.ACTION_LOCATION_CHANGED flg=0x10 (has extras) } in com.company.app.library.activity.MyActivity$LocationReceiver@40f45bb8
I cannot use the debugger to look at the app’s state as I cannot reproduce this error, so I’m reliant on analytics logs.
What does this exception actually mean? i.e. what is the problem in receiving it?
asked Oct 31, 2011 at 10:00
1
This means that there is an uncaught exception inside onReceive method.
Take a look on what can cause it… difficult to say without code and without more detailed stacktrace.
answered Oct 31, 2011 at 10:02
rciovatirciovati
27.4k6 gold badges81 silver badges101 bronze badges
Another possibility is that there’s more information a bit further down the log.
Example: I just had this error, and the log data looked like:
java.lang.RuntimeException: Error receiving broadcast Intent { act=com.example.bluetooth.le.ACTION_DATA_AVAILABLE flg=0x10 (has extras) } in myAppName.BlunoLibrary$5@41f792f8
at LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:778)
at Handler.handleCallback(Handler.java:733)
at Handler.dispatchMessage(Handler.java:95)
...bunch of internal android stuff...
Caused by: java.lang.NullPointerException
at myAppName.MainActivity.onSerialReceived(MainActivity.java:96) <-- hey look, my code screwed up!
at myAppName.BlunoLibrary$5.onReceive(BlunoLibrary.java:327)
at LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:768)
at Handler.handleCallback(Handler.java:733)
...bunch of other normal-looking callstack stuff...
That secondary «caused by» gave a very straightforward location where I had made a mistake.
answered Oct 8, 2015 at 23:53
ArtHareArtHare
1,75819 silver badges22 bronze badges
1
Another possible reason is that you are not unregistering the receiver in the activity’s onPause() method.
answered Feb 19, 2012 at 3:04
rOrligrOrlig
2,4694 gold badges35 silver badges47 bronze badges
-
Android device: Various devices
-
Android OS version: 4,5,6,7
-
Google Play Services version: 3.0.0
-
Firebase/Play Services SDK version: 12.0.1
implementation ‘com.google.android.gms:play-services-analytics:12.0.1’
implementation ‘com.google.android.gms:play-services-ads:12.0.1’
implementation ‘com.google.android.gms:play-services-auth:12.0.1’
implementation ‘com.google.firebase:firebase-core:12.0.1’
implementation ‘com.google.firebase:firebase-database:12.0.1’
implementation ‘com.google.firebase:firebase-auth:12.0.1’
implementation ‘com.google.firebase:firebase-storage:12.0.1’
implementation ‘com.google.firebase:firebase-messaging:12.0.1’
implementation ‘com.google.firebase:firebase-invites:12.0.1’
implementation ‘com.google.firebase:firebase-perf:12.0.1’
The app is keep crashing on various range of devices and OS versions,
Crash on Fabric:
LoadedApk.java line 662
android.app.LoadedApk.forgetReceiverDispatcher
*note that the same crash appears in different lines in LoadedApk.java
Fatal Exception: java.lang.RuntimeException: Error receiving broadcast Intent { act=android.net.conn.CONNECTIVITY_CHANGE flg=0x8000010 (has extras) } in com.google.firebase.iid.e@4207f700
at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:773)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:176)
at android.app.ActivityThread.main(ActivityThread.java:5319)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
at dalvik.system.NativeStart.main(NativeStart.java)
Caused by java.lang.IllegalArgumentException: Receiver not registered: com.google.firebase.iid.e@4207f700
at android.app.LoadedApk.forgetReceiverDispatcher(LoadedApk.java:662)
at android.app.ContextImpl.unregisterReceiver(ContextImpl.java:1702)
at com.google.firebase.iid.zzad.onReceive(Unknown Source)
at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:763)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:176)
at android.app.ActivityThread.main(ActivityThread.java:5319)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
at dalvik.system.NativeStart.main(NativeStart.java)
I have tried to reproduce this issue on different OS versions and devices, by connect/disconnect network while using the application but unable to reproduce it.
Содержание
- Fatal Exception: java.lang.RuntimeException: Error receiving broadcast Intent #827
- Comments
- Error receiving broadcast Intent android.intent.action.DOWNLOAD_COMPLETE #10
- Comments
- Exception: java.lang.RuntimeException: Error receiving broadcast Intent android.intent.action.DOWNLOAD_COMPLETE #117
- Comments
- java.lang.RuntimeException: Error receiving broadcast Intent #421
- Comments
Fatal Exception: java.lang.RuntimeException: Error receiving broadcast Intent #827
Android device: Various devices
Android OS version: 4,5,6,7
Google Play Services version: 3.0.0
Firebase/Play Services SDK version: 12.0.1
implementation ‘com.google.android.gms:play-services-analytics:12.0.1’
implementation ‘com.google.android.gms:play-services-ads:12.0.1’
implementation ‘com.google.android.gms:play-services-auth:12.0.1’
implementation ‘com.google.firebase:firebase-core:12.0.1’
implementation ‘com.google.firebase:firebase-database:12.0.1’
implementation ‘com.google.firebase:firebase-auth:12.0.1’
implementation ‘com.google.firebase:firebase-storage:12.0.1’
implementation ‘com.google.firebase:firebase-messaging:12.0.1’
implementation ‘com.google.firebase:firebase-invites:12.0.1’
implementation ‘com.google.firebase:firebase-perf:12.0.1’
The app is keep crashing on various range of devices and OS versions,
Crash on Fabric:
LoadedApk.java line 662
android.app.LoadedApk.forgetReceiverDispatcher
*note that the same crash appears in different lines in LoadedApk.java
Fatal Exception: java.lang.RuntimeException: Error receiving broadcast Intent < act=android.net.conn.CONNECTIVITY_CHANGE flg=0x8000010 (has extras) >in com.google.firebase.iid.e@4207f700
at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:773)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:176)
at android.app.ActivityThread.main(ActivityThread.java:5319)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
at dalvik.system.NativeStart.main(NativeStart.java)
Caused by java.lang.IllegalArgumentException: Receiver not registered: com.google.firebase.iid.e@4207f700
at android.app.LoadedApk.forgetReceiverDispatcher(LoadedApk.java:662)
at android.app.ContextImpl.unregisterReceiver(ContextImpl.java:1702)
at com.google.firebase.iid.zzad.onReceive(Unknown Source)
at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:763)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:176)
at android.app.ActivityThread.main(ActivityThread.java:5319)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
at dalvik.system.NativeStart.main(NativeStart.java)
I have tried to reproduce this issue on different OS versions and devices, by connect/disconnect network while using the application but unable to reproduce it.
The text was updated successfully, but these errors were encountered:
Источник
Error receiving broadcast Intent android.intent.action.DOWNLOAD_COMPLETE #10
Hi there!
I’m using this plugin as update tool, and when I just about to finish downloading, as logs displayed at 99%, the app shutdown.
My code was almost the same as the example, but not in main.dart , and using custom event to handle the event change.
The text was updated successfully, but these errors were encountered:
Hi,
can you please provide output from flutter doctor -v ? Looks like DOWNLOAD_COMPLETE could not be delivered from android download manager to the plugin listener.
Is logcat showing any StackTrace? That would be helpful.
Hi, it’s been a month since this issue has been created, and currently I’m not using this package, so I will be back when I test this again, cause I’m busy in other things, sorry.
Flutter version is 1.2.1 when this happened.
Does the problem still persists in 2.0.1?
Bug still exists in 2.0.1
Ok, after having success with example project I was able to pinpoint the problem.
It was misconfiguration on my side, in AndroidManifest.xml «provider» node should go inside «application» node, not in root node.
As this error is similar to original poster error I suppose it’s the same thing.
I believe this can be closed.
Hi, thanks for the info. I will update the docs.
Источник
Exception: java.lang.RuntimeException: Error receiving broadcast Intent android.intent.action.DOWNLOAD_COMPLETE #117
Thread: main, Exception: java.lang.RuntimeException: Error receiving broadcast Intent < act=android.intent.action.DOWNLOAD_COMPLETE flg=0x10 pkg=com.lw1a2.myeslpod (has extras) >in com.lw1a2.myeslpod.bn@43137d50
at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:780)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5083)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
at dalvik.system.NativeStart.main(Native Method) Caused by: android.content.ActivityNotFoundException: No Activity found to handle Intent < act=android.intent.action.INSTALL_PACKAGE typ=application/vnd.android.package-archive flg=0x10000000 >
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1690)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1436)
at android.app.Activity.startActivityForResult(Activity.java:3433)
at android.app.Activity.startActivityForResult(Activity.java:3394)
at android.app.Activity.startActivity(Activity.java:3629)
at android.app.Activity.startActivity(Activity.java:3597)
at com.lw1a2.myeslpod.bn.e(Unknown Source)
at com.lw1a2.myeslpod.bn.onReceive(Unknown Source)
at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:770) . 9 more
Thread: main, Exception: java.lang.RuntimeException: Error receiving broadcast Intent < act=android.intent.action.DOWNLOAD_COMPLETE flg=0x10 pkg=com.lw1a2.myeslpod (has extras) >in com.lw1a2.myeslpod.bn@43137d50
at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:780)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5083)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
at dalvik.system.NativeStart.main(Native Method) Caused by: android.content.ActivityNotFoundException: No Activity found to handle Intent < act=android.intent.action.INSTALL_PACKAGE typ=application/vnd.android.package-archive flg=0x10000000 >
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1690)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1436)
at android.app.Activity.startActivityForResult(Activity.java:3433)
at android.app.Activity.startActivityForResult(Activity.java:3394)
at android.app.Activity.startActivity(Activity.java:3629)
at android.app.Activity.startActivity(Activity.java:3597)
at com.lw1a2.myeslpod.Upgrade.install(Unknown Source)
access$5
at com.lw1a2.myeslpod.Upgrade.onReceive(Unknown Source)
at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:770) . 9 more
The text was updated successfully, but these errors were encountered:
Источник
java.lang.RuntimeException: Error receiving broadcast Intent #421
java.lang.RuntimeException: Error receiving broadcast Intent < act=com.yanzhenjie.permission.bridge flg=0x10 >in com.yanzhenjie.permission.bridge.Messenger@2586506
at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$-android_app_LoadedApk$ReceiverDispatcher$Args_52651(LoadedApk.java:1329)
at android.app.-$Lambda$aS31cHIhRx41653CMnd4gZqshIQ.$m$7(Unknown Source:4)
at android.app.-$Lambda$aS31cHIhRx41653CMnd4gZqshIQ.run(Unknown Source:39)
at android.os.Handler.handleCallback(Handler.java:794)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:176)
at android.app.ActivityThread.main(ActivityThread.java:6651)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:824)
Caused by: java.lang.IllegalArgumentException: Receiver not registered: com.yanzhenjie.permission.bridge.Messenger@2586506
at android.app.LoadedApk.forgetReceiverDispatcher(LoadedApk.java:1197)
at android.app.ContextImpl.unregisterReceiver(ContextImpl.java:1459)
at android.content.ContextWrapper.unregisterReceiver(ContextWrapper.java:655)
at com.yanzhenjie.permission.bridge.Messenger.unRegister(Messenger.java:49) (#pluginId:host#)
at com.yanzhenjie.permission.bridge.RequestExecutor.onCallback(RequestExecutor.java:96) (#pluginId:host#)
at com.yanzhenjie.permission.bridge.Messenger.onReceive(Messenger.java:54) (#pluginId:host#)
at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$-android_app_LoadedApk$ReceiverDispatcher$Args_52651(LoadedApk.java:1319)
. 9 more
The text was updated successfully, but these errors were encountered:
mMessenger maybe has been change when recall onCallback
But I dont has enought log to prove
Received, I will study it.
我这边也遇到了类似的 bug,使用的是 2.0.1 版本
2.0.3 版本 这个bug还在 @yanzhenjie HuaWei/EMOTION Android 9,level 28
Источник
Im currently working on a project and I keep running into the error
java.lang.RuntimeException: Error receiving broadcast Intent { act=android.net.wifi.WIFI_AP_STATE_CHANGED flg=0x4000010 (has extras) } in cn.ingenic.glasssync.utils.WifiAPUtils$1@428319e
Reading the logs further I also see a null pointer exception where it says:
Caused by: java.lang.NullPointerException: println needs a message
01-06 10:57:26.272 12372 12372 E AndroidRuntime: at android.util.Log.println_native(Native Method)
01-06 10:57:26.272 12372 12372 E AndroidRuntime: at android.util.Log.e(Log.java:249)
01-06 10:57:26.272 12372 12372 E AndroidRuntime: at cn.ingenic.glasssync.utils.WifiAPUtils.getValidApSsid(WifiAPUtils.java:225)
01-06 10:57:26.272 12372 12372 E AndroidRuntime: at cn.ingenic.glasssync.utils.WifiAPUtils$1.onReceive(WifiAPUtils.java:202)
When I check line 225 in WifiAPUtils.java and replace it with a valid string I then get the error
01-11 00:00:50.590 29176 29217 E AndroidRuntime: FATAL EXCEPTION: Thread-2
01-11 00:00:50.590 29176 29217 E AndroidRuntime: Process: cn.ingenic.glasssync:remote, PID: 29176
01-11 00:00:50.590 29176 29217 E AndroidRuntime: java.lang.ExceptionInInitializerError
01-11 00:00:50.590 29176 29217 E AndroidRuntime: at com.baidu.location.Jni.j(Unknown Source:0)
01-11 00:00:50.590 29176 29217 E AndroidRuntime: at com.baidu.location.t$a.X(Unknown Source:8)
01-11 00:00:50.590 29176 29217 E AndroidRuntime: at com.baidu.location.ae.run(Unknown Source:10)
01-11 00:00:50.590 29176 29217 E AndroidRuntime: Caused by: java.lang.IllegalStateException: no found the liblocSDK4d.so file, please correct settings
Would anyone happen to know what could be the cause of this error here is the snippet of the code that could be potentially causing this error:
private BroadcastReceiver mWifiStateBroadcastReceiver = new BroadcastReceiver() {
u/Overridepublic void onReceive(Context context, Intent intent) {Log.i(TAG,"WifiAPUtils onReceive: "+intent.getAction());if(WIFI_AP_STATE_CHANGED_ACTION.equals(intent.getAction())) {int cstate = intent.getIntExtra(EXTRA_WIFI_AP_STATE, -1);if(cstate == WIFI_AP_STATE_ENABLED) {if(mHandler != null)mHandler.sendEmptyMessage(MESSAGE_AP_STATE_ENABLED);
/*notify glass to reconnect*/String ssid = getValidApSsid(context);String pw = getValidPassword(context);int security = getValidSecurity(context);SettingModule.getInstance(context).sendWifiApInfo(ssid, pw, security);
}if(cstate == WIFI_AP_STATE_DISABLED || cstate == WIFI_AP_STATE_FAILED) {if(mHandler != null)mHandler.sendEmptyMessage(MESSAGE_AP_STATE_FAILED);}}}};
public enum WifiCipherType {WIFICIPHER_NOPASS, WIFICIPHER_WPA, WIFICIPHER_WEP, WIFICIPHER_INVALID, WIFICIPHER_WPA2}
public String getValidApSsid(Context context) {try {Method method = mWifiManager.getClass().getMethod("getWifiApConfiguration");WifiConfiguration configuration = (WifiConfiguration)method.invoke(mWifiManager);return configuration.SSID;} catch (Exception e) {Log.e(TAG,"testing" + e.getMessage());return null;}}
-
Thread starter
Erel
-
Start date
Aug 2, 2012 -
Similar Threads
Similar Threads
- Status
- Not open for further replies.
Old tutorial. Don’t use services. Use receivers.
Broadcast receivers are program components that can handle broadcasted messages. These messages usually notify about a system event.
There are two types of receivers in Android: statically registered receivers and dynamically registered receivers.
Static registered receivers are receivers that are declared in the manifest file.
Dynamic registered receivers are registered at runtime by calling the Java registerReceiver method.
In Basic4android you can register dynamic receivers with the BroadcastReceiver library. PhoneEvents and SmsInterceptor objects from the Phone library also use dynamic registration to listen for common intents.
Difference between static and dynamic receivers
The main difference between the two types of receivers is that dynamic receivers listen to intents as long as the process is running.
Static receivers always work. If the process is not running then it will be created.
Normal processes eventually get killed. This means that you cannot rely on dynamic receivers to intercept intents when your application is in the background. A possible workaround is to call Service.StartForeground in the service. This will prevent the process from being killed. However this will also add an ongoing notification icon (see the Services tutorial for more information).
So if you need to always listen for a specific type of intents then you may prefer to use a static receiver. Note that some intents can only be intercepted with dynamic receivers.
Static receivers
Each service module in Basic4android is made of two components. The service and a receiver. The receiver responsibility is to delegate broadcast intents to the service. For example when you call StartServiceAt, it is the receiver that actually intercepts the intent and wakes the service.
If we want to listen for intents we need to define an intent filter in the manifest file. See this link for more information about intent filters.
For example if we want to listen for intents with the action: android.provider.Telephony.SMS_RECEIVED we will need to add the following manifest editor code:
AddPermission(android.permission.RECEIVE_SMS)
AddReceiverText(s1,
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>)
s1 is the name of the service module that the intent will be delegated to.
We also add the RECEIVE_SMS permission which is required in this case.
Once this program is installed the service will be started each time that an Sms message arrives. It doesn’t matter whether the process is running or not.
In our Service_Start event we check the intent action. If it fits then the messages will be parsed from the intent. This is done with the help of the Reflection library:
'Service module
Sub Process_Globals
Type Message (Address As String, Body As String)
End Sub
Sub Service_Create
End Sub
Sub Service_Start(startingIntent As Intent)
If startingIntent.Action = "android.provider.Telephony.SMS_RECEIVED" Then
Dim messages() As Message
messages = ParseSmsIntent(startingIntent)
For i = 0 To messages.Length - 1
Log(messages(i))
Next
End If
Service.StopAutomaticForeground
End Sub
'Parses an SMS intent and returns an array of messages
Sub ParseSmsIntent (in As Intent) As Message()
Dim messages() As Message
If in.HasExtra("pdus") = False Then Return messages
Dim pdus() As Object
Dim r As Reflector
pdus = in.GetExtra("pdus")
If pdus.Length > 0 Then
Dim messages(pdus.Length) As Message
For i = 0 To pdus.Length - 1
r.Target = r.RunStaticMethod("android.telephony.SmsMessage", "createFromPdu", _
Array As Object(pdus(i)), Array As String("[B"))
messages(i).Body = r.RunMethod("getMessageBody")
messages(i).Address = r.RunMethod("getOriginatingAddress")
Next
End If
Return messages
End Sub
Update 2018: Static intent filters will cause the service to start while the app is not in the foreground. This means that on newer devices it will only work with B4A v8+ and that we need to call Service.StopAutomaticForeground once the task has completed.
https://www.b4x.com/android/forum/threads/automatic-foreground-mode.90546/#post-572424
Last edited: Jan 13, 2023
-
#2
Thanks for the info Erel it seems to be what I need. However, when I added an S1 service module to my app with the code you gave and made the changes to the manifest file I got the following java error in the log:
java.lang.Exception: Sub service_create signature does not match expected signature.
and a msgbox on screen saying «Sorry!» The application has stopped unexpectedly, Please try again.
What have I done wrong or failed to do?
Thanks.
-
#3
Please start a new thread for this question and also upload your project (File — Export as zip).
-
#4
Using this method of SMS interception: I am wondering if there is a way to «trap» the intercepted message and not display to the user in the SMS manager
Just like in SMS Interceptor, you can return «True» from the handling sub to prevent this SMS being shown to the user…
Thanks
flyingbag
-
#5
You will not be able to abort the broadcast with the static intent filter.
-
#6
Intercepting multi part sms
I am working on a project that will receive large sms messages..i.e multipart messages.
Since the interceptor receives one part at a time as a separate SMS, is there a way of looking at the UDH so that I can piece the messages together or some way that the interceptor can concatenate the messages into a single message?
Thanks!
:sign0104:
-
#7
SMS over 160 chars
Hi guys,
do you know if Phone Library implements SMS_Interceptor for sms with most of 160 chars?
TX
-
#8
It is not documented. You will need to test it. It seems from the native source code that it should handle multipart messages correctly.
-
#9
Hi Erel,
it is late to initialize sms interceptor on intent action SMS_RECEIVED? I cannot get into SI_MessageReceived Sub.
Thnx
-
#10
Hi Erel,
it is late to initialize sms interceptor on intent action SMS_RECEIVED? I cannot get into SI_MessageReceived Sub.
Thnx
Yes it is possible but another app is blocking sms_intercept to work.
-
#11
Hi Erel,
I’m trying to use your method to intercept Share Intents (android.intent.action.SEND) and search intents (android.intent.action.SEARCH).
But for some reason I don’t get it working.
I’ve added the following Code to the manifest editor:
AddReceiverText(SuchIntent,
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>)
AddReceiverText(SuchIntent,
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>)
The service Module «SuchIntent» contains the following code:
'Service module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Service_Create
End Sub
Sub Service_Start (StartingIntent As Intent)
Dim keyword As String
If StartingIntent.Action = "android.intent.action.SEND" Then
keyword = StartingIntent.GetExtra("android.intent.extra.TEXT")
Log("Extras:"&StartingIntent.ExtrasToString)
Log("GetData:"&StartingIntent.GetData)
Log("GetExtra"&StartingIntent.GetExtra("android.intent.extra.TEXT"))
Log(StartingIntent.HasExtra("EXTRA_TEXT"))
Else If StartingIntent.Action = "android.intent.action.SEARCH" Then
keyword = StartingIntent.GetExtra("query")
Else
Return
End If
Suche.SearchState = Suche.SS_RESULT_SUCCESS
Suche.SearchResult = keyword
DB.AddVerlauf(keyword)
StartActivity(Suche)
End Sub
Sub Service_Destroy
End Sub
If I open the phones browser, select some text and the either click on Share or Search my Application isn’t shown in the list.
Is there something wrong with my code, or is this a Bug in B4A?
-
#12
The SEND intent is sent to an activity not receiver. You should add the intent filter to an activity.
-
#13
Hi Erel,
thanks for pointing this out. I changed the Manifest text to:
AddActivityText(SuchIntent,
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>)
AddActivityText(SuchIntent,
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>)
For some reason, the Application still doesn’t appear in the Share popup.
-
#14
Is SuchIntent an activity? Try to change the mimeType to text/* or */*.
-
#15
Just figured it out myself: The intent doesn’t work in Service Modules, but it works in Activity Modules.
-
#16
SmsInterceptor problem
when i received new sms i have this error. how can i solve it ??
java.lang.RuntimeException: Error receiving broadcast Intent { act=android.provider.Telephony.SMS_RECEIVED flg=0x30 (has extras) } in anywheresoftware.b4a.phone.PhoneEvents$SMSIntercep [email protected]
:sign0085:
-
#17
Please start a new thread for this question. And also include the full error message from the logs.
-
#18
android.provider.Telephony.SMS_SENT
i have add in manifest
<action android:name=»android.provider.Telephony.SMS_SENT» />
AddPermission(android.permission.RECEIVE_SMS)
AddReceiverText(SerSMS,
<intent-filter>
<action android:name=»android.provider.Telephony.SMS_RECEIVED» />
<action android:name=»android.provider.Telephony.SMS_SENT» />
</intent-filter>)
but…. how do intercept sms sent in Service?
-
#19
Where did you see this action? I don’t think that there is such an intent in Android. Note that the updated Phone library allows you to track outgoing messages (when your process is running).
- Status
- Not open for further replies.
-
Sticky
I created a broadcast receiver in the main activity and the background service which is sending broadcast intents. The application crashes each time I try to run it and the Log displays the following error message:
10-04 13:30:43.218:
ERROR/AndroidRuntime(695):
java.lang.RuntimeException: Error
receiving broadcast Intent {
action=com.client.gaitlink.CommunicationService.action.LOGIN_STATUS_UPDATE
(has extras) } in
[email protected]
The broadcast message is sent from CommunicationService class in the following method:
private void announceLoginStatus(){
Intent intent = new Intent(LOGIN_STATUS_UPDATE);
intent.putExtra(SERVER_MESSAGE, mServerResponseMessage);
intent.putExtra(SESSION_STRING, mSessionString);
sendBroadcast(intent);
}
where
String LOGIN_STATUS_UPDATE = "com.client.gaitlink.CommunicationService.action.LOGIN_STATUS_UPDATE"
in the main activity the following broadcast reveiver is defined:
public class LoginStatusReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
String serverMessage = intent.getStringExtra(CommunicationService.SERVER_MESSAGE);
String sessionString = intent.getStringExtra(CommunicationService.SESSION_STRING);
userInfo.setSessionString(sessionString);
saveSettings();
}
}
and registered in onResume method:
IntentFilter loginStatusFilter;
loginStatusFilter = new IntentFilter(CommunicationService.LOGIN_STATUS_UPDATE);
loginStatusReceiver = new LoginStatusReceiver();
registerReceiver(loginStatusReceiver, loginStatusFilter);
And the manifest file includes the following:
<activity android:name=".GaitLink"
android:label="@string/app_name">
<intent-filter>
...
<action android:name="com.client.gaitlink.CommunicationService.action.LOGIN_STATUS_UPDATE" />
</intent-filter>
</activity>
I would really appreciate if anyone could explain why the Log displays the message above and the application crashes.
Thanks!
При попытке протестировать broadCastReceiver с ConnectivityManager.CONNECTIVITY_ACTION, приложение аварийно завершает работу и logcat говорит об Error receiving broadcast Intent. пожалуйста, дайте мне знать, что мне не хватает.
Код:
public class wifi_socket_01 extends Activity {
TextView tv_conn_status;
TextView tv_conn_ssid;
TextView tv_conn_speed;
TextView tv_conn_strengt;
TextView tv_conn_ip;
EditText et_ip;
ToggleButton tobBtn_connect;
EditText et_msg;
Button btn_send;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SetUpAllViews(R.layout.activity_main);
displayWiFiStates();
this.registerReceiver(this.myWiFiReceiver,
new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
}
private BroadcastReceiver myWiFiReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
NetworkInfo networkInfo = intent.getParcelableExtra(ConnectivityManager.EXTRA_EXTRA_INFO);
if (networkInfo.getType() == ConnectivityManager.TYPE_WIFI) {
displayWiFiStates();
}
}
};
private void SetUpAllViews(int layout) {
// TODO Auto-generated method stub
setContentView(layout);
tv_conn_status = (TextView) findViewById(R.id.tv_conn_status);
tv_conn_ssid = (TextView) findViewById(R.id.tv_conn_ssid);
tv_conn_speed = (TextView) findViewById(R.id.tv_conn_speed);
tv_conn_strengt = (TextView) findViewById(R.id.tv_conn_strength);
tv_conn_ip = (TextView) findViewById(R.id.tv_conn_ip);
et_ip = (EditText) findViewById(R.id.et_ip);
tobBtn_connect = (ToggleButton) findViewById(R.id.togbtn_connect);
et_msg = (EditText) findViewById(R.id.et_msg);
btn_send = (Button) findViewById(R.id.btn_send);
}
protected void displayWiFiStates() {
// TODO Auto-generated method stub
String service = Context.CONNECTIVITY_SERVICE;
ConnectivityManager myConnManager = (ConnectivityManager) getSystemService(service);
NetworkInfo myNetworkInfo = myConnManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
WifiManager myWifiManager = (WifiManager)getSystemService(Context.WIFI_SERVICE);
WifiInfo myWiFiInfo = myWifiManager.getConnectionInfo();
if(myNetworkInfo.isConnected()) {
tv_conn_ip.setText("IP: "+myWiFiInfo.getIpAddress());
}else {
tv_conn_status.setText("Disconnected");
}
}
}
LogCat:
11-08 10:26:57.645: E/AndroidRuntime(15348): FATAL EXCEPTION: main
11-08 10:26:57.645: E/AndroidRuntime(15348): Process: com.example.wifi_socket_01, PID:
15348
11-08 10:26:57.645: E/AndroidRuntime(15348): java.lang.RuntimeException: Error
receiving broadcast Intent { act=android.net.conn.CONNECTIVITY_CHANGE flg=0x4000010
(has extras) } in [email protected]
11-08 10:26:57.645: E/AndroidRuntime(15348): at
android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:782)
11-08 10:26:57.645: E/AndroidRuntime(15348): at a
ndroid.os.Handler.handleCallback(Handler.java:733)
11-08 10:26:57.645: E/AndroidRuntime(15348): at
android.os.Handler.dispatchMessage(Handler.java:95)
11-08 10:26:57.645: E/AndroidRuntime(15348): at
android.os.Looper.loop(Looper.java:157)
11-08 10:26:57.645: E/AndroidRuntime(15348): at
android.app.ActivityThread.main(ActivityThread.java:5293)
11-08 10:26:57.645: E/AndroidRuntime(15348): at
java.lang.reflect.Method.invokeNative(Native Method)
11-08 10:26:57.645: E/AndroidRuntime(15348): at
java.lang.reflect.Method.invoke(Method.java:515)
11-08 10:26:57.645: E/AndroidRuntime(15348): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
11-08 10:26:57.645: E/AndroidRuntime(15348): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
11-08 10:26:57.645: E/AndroidRuntime(15348): at
dalvik.system.NativeStart.main(Native Method)
11-08 10:26:57.645: E/AndroidRuntime(15348): Caused by: java.lang.NullPointerException
11-08 10:26:57.645: E/AndroidRuntime(15348): at
com.example.wifi_socket_01.MainActivity$1.onReceive(MainActivity.java:48)
11-08 10:26:57.645: E/AndroidRuntime(15348): at
android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:772)
08 нояб. 2014, в 11:23
Поделиться
Источник
3 ответа
попробуйте это вместо этого:
измените свой
NetworkInfo networkInfo = intent.getParcelableExtra(ConnectivityManager.EXTRA_EXTRA_INFO);
в
ConnectivityManager cm =
(ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = cm.getActiveNetworkInfo();
из документов: EXTRA_EXTRA_INFO
Ключ поиска для строки, которая предоставляет необязательную дополнительную информацию о состоянии сети.
Ключ поиска для строки, которая предоставляет необязательную дополнительную информацию о состоянии сети. Информация может быть передана из нижних сетевых уровней, и ее значение может быть специфичным для определенного типа сети. Получите его с помощью getStringExtra (String).
Постоянное значение: «extraInfo»
поэтому мы нашли объяснение корня проблемы, он никогда не возвращает networkInfo. Все о состоянии сети.
Надеюсь, поможет 
Spurdow
08 нояб. 2014, в 07:39
Поделиться
Вероятно, вам не хватает правильных прав Android в AndroidManifest:
<!-- ANDROID PERMISSIONS -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Rowland Mtetezi
21 дек. 2015, в 20:01
Поделиться
Я столкнулся с тем же вопросом, он оказался нулевым указателем внутри функции onReceive, я исправил это, изменив
Boolean up = cm.getActiveNetworkInfo().isConnected();
в
NetworkInfo info = cm.getActiveNetworkInfo();
boolean up = false;
if(info != null && info.isConnected()){
up = true;
}
Я тоже на Android N, это происходит на службе, которая работает в потоке пользовательского интерфейса
Fire Crow
14 фев. 2018, в 02:45
Поделиться
Ещё вопросы
- 0Почему это печатается дважды?
- 1Расчет смещений после поворота квадрата от угла
- 0Один раз Войти через Jquerymobile
- 0Обновить нулевое поле из того же поля, если не ноль
- 1Невозможно запустить файл .Robot в окнах Pycharm
- 0Использование пользовательской страницы просмотра для предварительного просмотра изображения в Sonata Admin в проекте Symfony 2
- 1Использование Aforge.net или C # для получения или установки свойств камеры (например, время экспозиции)
- 1Время отображается неправильно на Heroku, но правильно на localhost, используя момент
- 0Управление одним из значений вектора пар в C ++
- 0Есть ли какой-нибудь JQuery, который поможет встроить электронную таблицу Excel для веб-страницы?
- 1возвращать последнюю дату и значение каждого месяца в пандах
- 1Транзакции Entity Framework
- 1Недопустимая инструкция: ошибка 4 при запуске любой программы Tensorflow
- 0Mysql — умножить два столбца и вычесть разницу
- 1как получить и установить параметры в Camel HTTP Proxy
- 1Проблема в разборе JSON String
- 1Python, Pandas, чтобы соответствовать фрейму данных и указать результаты из списка
- 1Android добавить «…» в конце textview _EDIT
- 1Нестандартное использование уведомления об ожидании в параллельных программах Java
- 0JPlayer не может играться в IE8
- 0получить идентификатор всех отмеченных флажков в div
- 0Получить все значения из одного столбца в MySQL PDO
- 1добавить поле в модуль odoo localhost
- 1Привязка к карте в универсальном приложении
- 1W8.1 Live SDK 5.6 — LiveAuthClient.InitializeAsync System.NullReferenceException
- 1Почему Integer.parseInt («53.6») не работает?
- 0показ QMessageBox с QThread, когда графический интерфейс заморожен
- 0Обновить массив, но не добавлять новые элементы
- 1Как автоматически выгружать память, когда old-gen из jvm превышает некоторое соотношение?
- 1RallyRestApi.dll не распознает объект RallyRestApi
- 0текст вне div в chrome (css)
- 0Как выбрать товары, где цена на 20% выше или ниже?
- 0Проверьте, существует ли строка, вставьте соответственно
- 1Apache POI: Word получить размеры изображения
- 1Самое простое в мире приложение vue.js / vuefire / firebase. Но не могу прочитать значение
- 1строка удаленного подключения от Webmatrix 3 к Microsoft SQL Server
- 0Я хотел бы добавить и воспроизвести видео в моей html почте, но не смог найти правильный способ сделать это
- 0Развертывание приложения MEAN на Heroku дает ошибку H10 и статус 503
- 0MySQL возвращает только 1 строку, хотя должно быть больше
- 1JMenuCheckBox: Как установить ускоритель только с 1 клавишей
- 0выберите запись, только если в mysql указаны конкретные связанные значения
- 0загрузить файл по определенному маршруту не работает
- 1Как параметризировать метку даты в запросе pyODBC?
- 1CKEditor: игнорирование его config.js
- 1Лучший способ сравнить значения данного столбца 2 на 2
- 1Альтернативная запись в Play Store
- 1Служба WCF получает все поля, отправленные SoapUI-Request, только если они отображаются в определенном порядке.
- 1Как применить декораторы к функциям Python, написанным на C?
- 0Плагин jquery передает значение при возврате функции
- 0Подтверждение: Введено — целое число? QT c ++



