getActivity() returns null in Fragment function
I have a fragment (F1) with a public method like this public void asd() { if (getActivity() == null) { Log.d(“yes”,”it is null”); … Read more
I have a fragment (F1) with a public method like this public void asd() { if (getActivity() == null) { Log.d(“yes”,”it is null”); … Read more
What does need to be imported or how can I call the Layout inflater in places other than activity? public static void method(Context … Read more
This has me stumped, I was using this in Android 2.1-r8 SDK: ProgressDialog.show(getApplicationContext(), ….); and also in Toast t = Toast.makeText(getApplicationContext(),….); using getApplicationContext() … Read more
There has been a lot of posting about what these two contexts are.. But I’m still not getting it quite right As I … Read more
I’ve found the R.string pretty awesome for keeping hardcoded strings out of my code, and I’d like to keep using it in a … Read more
In various bits of Android code I’ve seen: public class MyActivity extends Activity { public void method() { mContext = this; // since … Read more
I am aware of the availability of Context.getApplicationContext() and View.getContext(), through which I can actually call Context.getPackageName() to retrieve the package name of … Read more
I have implemented a ListView in my Android application. I bind to this ListView using a custom subclass of the ArrayAdapter class. Inside … Read more
I couldn’t find a satisfying answer to this, so here we go: what’s the deal with Activity/Service.getApplication() and Context.getApplicationContext()? In our application, both … Read more
In an Android app, is there anything wrong with the following approach: public class MyApp extends android.app.Application { private static MyApp instance; public … Read more