wish that is any help with this scenario thx in advance
Is this AccountAuthenticatorActivity-extending class the main class /
activity of your application, or are you starting this activity yourself
from somewhere? The reason I ask is that starting a new project, making my
main activity extend AccountAuthenticatorActivity and testing
getApplicationContext() there worked fine - it gave a non-null result:
---
package net.testing;
import android.accounts.AccountAuthenticatorActivity;
import android.content.Context;
import android.os.Bundle;
import android.widget.Toast;
public class TestAccountAuthActivity extends AccountAuthenticatorActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Context c = getApplicationContext();
Toast.makeText(this, c == null ? "It's null!" : "It's valid",
Toast.LENGTH_LONG).show();
}
}
---
(It showed 'It's valid' on the screen as expected.)
Also, is there a reason that you set mContext when you appear to be using
the context immediately, and within the same body of code (therefore making
the assignment to a static member unnecessary)? It won't make any difference
to the result unless... you are doing something unusual with it elsewhere.
Are you *sure* the NullPointerException came from this line:
ContentResolver cr=mContext.getContentResolver();
? Could you perhaps show us your LogCat (screen snapshot?), showing the
lines where it indicates where in your source code it happens?
(You can easily check the value of mContext before you try to use it using
the Toast technique as a temporary way of seeing the answer, like I did.)
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en