开发者

How do I start an Activity from a Service?

So I've been searching around for a week or so, and it appears to be quite possible to start an Activity from a Service, the general order of things going like this:

    Intent myIntent = new Intent();
    myIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    myIntent.setComponent(new ComponentName("[package]", "[class]"));
    getApplication().startActivity(myIntent);

When t开发者_运维百科rying this from a WallpaperService, I'm getting what appears to be a wallpaper-specific error requires android.permission.BIND_WALLPAPER. Stack trace shows the startActivity as the culprit.

I have no idea how to give it this permission; I have tried putting android:permission="android.permission.BIND_WALLPAPER" on every tag in the manifest that'll take it, as well as <uses-permission android:name="android.permission.BIND_WALLPAPER" />

Notably, the debug view does have the warning:

WARN/PackageManager(59): Not granting permission android.permission.BIND_WALLPAPER to package (protectionLevel=3 flags=0xbe46)

General question being asked is in the title. Thanks in advance!


You want to put android:permission="android.permission.BIND_WALLPAPER" inside only the service tag and nowhere else.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜