-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SonyHomeBadger got an exception #175
Comments
Maybe my testing case is wrong. But that the caller applies counts in a background thread still is an issue. |
public final class ShortcutBadger{
public static void applyCountOrThrow(Context context, int badgeCount) throws ShortcutBadgeException {
if (sShortcutBadger == null) {
boolean launcherReady = initBadger(context);
if (!launcherReady)
throw new ShortcutBadgeException("No default launcher available");
}
try {
sShortcutBadger.executeBadge(context, sComponentName, badgeCount);
} catch (Exception e) {
throw new ShortcutBadgeException("Unable to execute badge", e);
}
}
}
public class SonyHomeBadger implements Badger {
private void executeBadgeByContentProvider(Context context, ComponentName componentName, int badgeCount) {
if (badgeCount < 0) {
return;
}
if (mQueryHandler == null) {
mQueryHandler = new AsyncQueryHandler(
context.getApplicationContext().getContentResolver()) {
};
}
insertBadgeAsync(badgeCount, componentName.getPackageName(), componentName.getClassName());
}
}
throw exception and catch by
device : Sony E6653 |
@McLoo i'm sorry, i am using the version:1.1.14, so maybe this issue should mark as resolve and close. |
i have upgraded to 1.1.17, and it worked! |
I guess this issue should be closed. |
This issue has been fixed so I close it. |
I called "applyCount" from a background thread and got this exception.
I used the "IsBadgeWorking?" app to try it, and then I got a crash.
Exception:
W/System.err: Caused by: java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
W/System.err: at android.os.Handler.(Handler.java:200)
W/System.err: at android.os.Handler.(Handler.java:114)
W/System.err: at android.content.AsyncQueryHandler.(AsyncQueryHandler.java:125)
W/System.err: at me.leolin.shortcutbadger.impl.SonyHomeBadger$1.(SonyHomeBadger.java:78)
W/System.err: at me.leolin.shortcutbadger.impl.SonyHomeBadger.executeBadgeByContentProvider(SonyHomeBadger.java:78)
W/System.err: at me.leolin.shortcutbadger.impl.SonyHomeBadger.executeBadge(SonyHomeBadger.java:42)
Crash:
02-21 09:52:29.051 20488-2674/me.leolin.isbadgeworking E/AndroidRuntime: FATAL EXCEPTION: AsyncQueryWorker
Process: me.leolin.isbadgeworking, PID: 20488
java.lang.SecurityException: Missing permission to insert badges
at android.os.Parcel.readException(Parcel.java:1629)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:183)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:135)
at android.content.ContentProviderProxy.insert(ContentProviderNative.java:476)
at android.content.ContentResolver.insert(ContentResolver.java:1244)
at android.content.AsyncQueryHandler$WorkerHandler.handleMessage(AsyncQueryHandler.java:96)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:168)
at android.os.HandlerThread.run(HandlerThread.java:61)
The text was updated successfully, but these errors were encountered: