Reputation: 29724
My immediate problem is solved as per my answer below. My environment (PC + devices) does not allow custom permissions in DEBUG builds.
I'm convinced I was able to run DEBUG builds fine a few weeks ago - hence the description of an "intermittent" error.
The code synced out on a different developer's machine, works fine on his device in DEBUG mode through Eclipse. On my devices, it does not work from his machine.
Also the DEBUG build from my machine works fine on this other device.
This leads me to question if something has gone wrong on my devices?
I have an intermittent "Permission Denial" problem with custom permission Intents
. It's one of those where the code is in production and works, but sometimes when making new builds, it stops working. I have only managed to fix it by luck before, through a process of reboot (device & pc), clean project, uninstall/reinstall, repeat etc... this is unacceptable.
As far as I can see I am doing everything correct for custom permissions on my Intents
that I am broadcasting within my app. But logcat is giving me the usual errors of:
on 4.2.1 (Galaxy Nexus) & 4.2.2 (Nexus 7), or
on 4.0 (S2) & 2.3.3 (Samsung Ace).
i.e. standard errors.
My MANIFEST says:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.test"
android:versionCode="1"
android:versionName="4.10.0.3" >
<permission
android:name="A_PERMISSION"
android:description="@string/broadcast_permission_desc"
android:label="@string/broadcast_permission_label"
android:permissionGroup="@string/broadcast_permission_group"
android:protectionLevel="signature" />
<uses-permission android:name="A_PERMISSION" />
etc.....
Those STRINGS are defined as (fwiw):
<string name="broadcast_permission_label">Private Broadcast</string>
<string name="broadcast_permission_desc">This permission allows the necessary components of the application to receive private broadcasts that are sent within the application.</string>
<string name="broadcast_permission_name">A_PERMISSION</string>
<string name="broadcast_permission_group">A_GROUP</string>
I have a method in my base APPLICATION subclass that I use to do the broadcasting:
public void sendBroadcast(Intent i)
{
// hardcoded custom permission
super.sendBroadcast(i, "A_PERMISSION");
}
I REGISTER for my BroadcastReceiver
from within a Fragment
like this:
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
// hardcoded custom permission
MyApp.getInstance().registerReceiver(myReceiver, myFilter,
"A_PERMISSION", null);
}
I have checked the following related questions without joy:
I think that covers similar questions on this site.
My problem is that its intermittent but wastes lots of time i.e. some builds work on all phones, some builds fail on all phones.
I wonder if this is an issue in one of the frameworks (either Android OS, or perhaps Eclipse / Android SDK). Unfortunately my googling only leads me to the more common issues with the common solutions.
Upvotes: 3
Views: 5507
Reputation: 29724
Final Solution - I agree it doesn't seem to make sense, but here it is:
I have 2 apps using the same permission - com.test
and com.runtest
.
As above, com.test
was broken for DEBUG builds. But I noticed that com.runtest
was still working.
Steps:
com.runtest
to confirm it was workingcom.runtest
to com.test
- in Eclipse (Android Tools...
Rename Application Package)com.test
com.test
app in Eclipse on my device - it
finally worked!So for some reason, overwriting the broken app with a working app changed something, and fixed my device.
Upvotes: 1