开发者

How do I get the Context from the Intent?

AccountAuthenticator.java:

Intent intent = new 开发者_如何学PythonIntent(context, AccountActivity.class);

AccountActivity.java:

In onCreate(Bundle aBundle) I want to say:

getIntent().getContext();

But getContext() does not exist.

How do I get the Context from the Intent ?

Since it's passed in the Intent constructor, I was expecting it to be available on arrival in the AccountActivity.


How do I get the Context from the Intent ?

You don't.

Since it's passed in the Intent constructor, I was expecting it to be available on arrival in the AccountActivity.

The Context is only used to help create the Intent routing information. Since an Intent can (and frequently does) live outside of any Context, an Intent cannot hold onto a Context.

I need the Service (i.e. Context) that created the Intent, so as to be able to create an AsyncTask taking it in the constructor.

You cannot do this, sorry.

If I don't do that I get: "java.lang.SecurityException: caller uid 10027 is different than the authenticator's uid", since the AsyncTask is doing Accountmanager am = Accountmanager.get(context).

This has nothing to do with AsyncTask. This has to do with processes, not threads.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜