Questions tagged [android-context]

Interface to global information about an application environment

Interface to global information about an application environment. This is an abstract class whose implementation is provided by the Android system. It allows access to application-specific resources and classes, as well as up-calls for application-level operations such as launching activities, broadcasting and receiving intents, etc.

Context - Android Developer

1980 questions
0
votes
1 answer

How obtain the Context object into a class extenging Fragment?

I am pretty new new in Android and I am finding some dificulties to do the following thing related to the Context. So I have an utility class that contain an utility method that create and return a Bitmap image, this is the code of my class: public…
AndreaNobili
  • 40,955
  • 107
  • 324
  • 596
0
votes
1 answer

Fragment getActivity not working

I am following this tutorial, and and trying to create a profile page for each individual user instead of albums. However, I am using fragments instead of activities and realise my code will be abit different to the tutorial. I have used the…
0
votes
1 answer

Getting Context of All Activities in Project Programmatically

I'm trying to create a function that globally changes a setting which is represented by a SharedPreference and can later be manually set for each activity. In the settings, I want to offer the user the ability to change the setting for every…
0
votes
1 answer

How to access DialogFragment from onEditorActionListener?

I'm building a search dialog for my app in which the user puts their search query in an EditText and presses enter, which should trigger the search. The following is from my onCreateDialog method: final AlertDialog.Builder builder = new…
trpnd
  • 455
  • 2
  • 10
0
votes
0 answers

Using different contexts on startActivity makes App restart itself

My app starts with a splashActivity. In my Application, I start all my Singleton classes, one of them is ActivityController (Simplified code): public class ActivityController { private static ActivityController INSTANCE = null; private…
Borja
  • 1,269
  • 1
  • 17
  • 30
0
votes
1 answer

Cannot figure out the context when launching an Intent from within a thread completion method

I am trying to launch a new intent after I have loaded data. I am using a handler that calls a method when the thread is complete and then in this method I am trying to launch a new Intent but my app is crashing every time. I have narrowed it down…
rplankenhorn
  • 2,075
  • 2
  • 22
  • 32
0
votes
0 answers

Why runs into NullpointerException when calling getSystemService(LOCATION_SERVICE)

I run into the NullPointerException while calling getSystemService(). I checked some posts before but can't figure out why it failed. public class GetGyroInfo extends Service implements LocationListener{ private float mLongAccl; private…
Hong
  • 526
  • 6
  • 21
0
votes
1 answer

Access Android activity stack from asynchronous thread?

There are a ton of activity stack related questions on StackOverflow, but I didn't really see any that answered the question I have. I'm working on an online game that (for now) has 3 different activities: Login/Register Menu (seen when logged in,…
Matt Huggins
  • 81,398
  • 36
  • 149
  • 218
0
votes
1 answer

ContextWrapper.getResources nullpointer when adding rows to TableLayout

I've edited the question to reflect the answer. I was instantiating a new Artists() every time the getArtists() DatabaseHelper method was called. So I deleted artists = new Artists(); in getArtists() in the DatabaseHelper class. Instead of…
0
votes
1 answer

converting a drawable to a bitmap giving me an error

i want to convert a drawable from an object to a bitmap, but when i try to use this Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), cardWriter.getCardImage()); it gives me an error wrong second argument expecting…
Martin Seal
  • 616
  • 2
  • 14
  • 32
0
votes
2 answers

Extending Application

I'd like to extend Application in my Android app. I've done this such that I've created an extended Application object called MyApplication and added it to the manifest. I'd now like to add some getters and setters to hold some information. It…
Andrew
  • 20,756
  • 32
  • 99
  • 177
0
votes
2 answers

Activity.this cannot be referenced from a static context

Well, the question is something which is similar to already asked questions on the forum but I couldn't find a suitable answer to my problem.My usersettingactivity class- public class UserSettingActivity extends PreferenceActivity implements…
0
votes
5 answers

AlertDialog and ArrayAdapter

I have an Adapter which extend ArrayAdapter. With this adapter class I manage a ListView inside MainActivity. I also have some buttons inside each row of the list and when I click on a button I want an AlertDialog to be shown. In doing so, I got an…
0
votes
1 answer

Update a fragment whenever page selected

I have 2 fragments in my App's MainActivity. One fragment will read data from Bluetooth Device and create a Database. Other will display this data (in BarGraph). It is working fine. But, the BarGraph is not updating dynamically when new data comes.…
0
votes
4 answers

How to get the Context of an Application in a Fragment

First I have this error message Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.database.sqlite.SQLiteDatabase android.content.Context.openOrCreateDatabase(java.lang.String, int,…