- Home /
Android plugin breaks when using receiver.
Hi, I'm trying to make a broadcast receiver to get data from my other application. The broadcast receiver was done in Java and works fine, when working just on Java. I made some dummy functions in it, to test that Unity can access the class and it can. Basically, whenever my sender sends the first message, the receiver crashes. My guess is that the problem is within the manifest, since I don't know Unity and Android too well. Here is the code snippet for the receiver manifest:
<receiver android:name="com.example.testing" >
<intent-filter>
<action android:name="com.example.testing" ></action>
</intent-filter>
</receiver>
When I run it on my Android device, it gives me java.lang.RuntimeException: Unable to instantiate receiver "com.example.testing" on path DexPathList [[zip file "/data/apps/com.example.testing-2.apk"], nativeLibraryDirectories... From what I understand the receiver android:name attribute is incorrect because when I change it, the error changes for the class I'm looking for. My class for the receiver in java is called MyReceiver, but that doesn't work either. Thank you for your help.
Answer by Edged · Jun 25, 2014 at 10:43 AM
In case anyone wonders, the problem was because my receiver was in default package, and the manifest has to point at the class, but if you are in default package and you write "MyReceiver" it still, for some reason thinks you are writing ".MyReceiver". Solution: put MyReceiver in some package, then access it through "smth.MyReceiver". Strangely, Eclipse manifest does not throw such errors. Possibly a Unity bug?
I'm sure you already know this, but Google docs state that data can be freely accessed between AP$$anonymous$$s that are signed with the same key.
Just seemed like a good piece of info to drop here.
Your answer
Follow this Question
Related Questions
Calling static jar function from Unity3D 0 Answers
How to use Android Api in Unity 1 Answer
No OpenGL Context in Unity above 2017.1.2f1 0 Answers
Using AndroidJavaClass in a java Unity3d plugin 0 Answers
Unity 3.5 Anroid problem 1 Answer