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
2 answers

invoke virtual method null context.getSystemService

I have this error appearing in my logcat, with no additional information. Attempt to invoke virtual method 'java.lang.Object android.content.Context.getSystemService(java.lang.String)' on a null object reference While debugging I found out that…
M3-n50
  • 803
  • 1
  • 13
  • 23
0
votes
2 answers

Use UserSingleton with null context (silent push notification)

I'm currently working on GCM notifications, especially on silent push notification. For the moment, I receive the silent notification, even when the app is closed (which is the aim of my notification). The problem is the code I am trying to execute…
0
votes
1 answer

Get Valid (Non-Null) Context For Android Instrumentation Test

I've looked at a lot of posts and read the documentation on Android Instrumentation Tests but cannot get my code to work. My scenario is that I can't use a mock context object, I need a valid one. I have tried using: @Before public void setUp()…
Aggressor
  • 13,323
  • 24
  • 103
  • 182
0
votes
1 answer

Android Permission Request: onRequestPermissionsResult is never called / reached - Possible Context Issue

Request Permissions: public class GooglePermissions extends ExternalClass { //... private void checkPermissions() { if (ContextCompat.checkSelfPermission(mContext, Manifest.permission.GET_ACCOUNTS) !=…
0
votes
1 answer

Android calling IntentService class from a Service Class

Can we call IntentService class from a running Service class . Intent myintentservice = new Intent(this, MyIntentService.class); startService(myintentservice); I using above lines of code in service class to start IntentService class. But then I…
0
votes
0 answers

Context Handling from ListFragment - Getting NullPointerException Error Attempt to invoke virtual method...Context.getResources()'

This is what I'm trying to do. I have a ListFragment that has a list of albums on the Main Activity of my app. When I longpress, I am creating a yes/no dialog and when the user presses Yes I am trying to run my delete Album method. However, I am met…
Laugh7
  • 167
  • 2
  • 2
  • 16
0
votes
1 answer

Glide with Fragment Context

This is related to Glide image loading with application context I have several Fragments hosted in an Activity, with a Fragment being replaced by another as the user navigates through the app. I'm passing a RequestManager into my MyFragment's…
terencey
  • 3,282
  • 4
  • 32
  • 40
0
votes
1 answer

Android - Context in ListFragment does'nt work when called from AsyncTask in other Activity

I want to refresh the List of a ListFragment. Therefore I created a method in my ListFragment: public void setAdapter(List valueList) { ArrayAdapter adapter = new ArrayAdapter(ctx, android.R.layout.simple_list_item_1,…
0
votes
4 answers

Android AsyncTask with ProgressDialog - Null object reference

I have an AsyncTask class in my Android app. My MainActivity calls a method in that class, but when I do, it has an issue with the ProgressDialog box in it. This is the error I am getting: java.lang.NullPointerException: Attempt to invoke virtual…
0
votes
1 answer

Android: Application context, force root intent to show upon launch

I am writing an Android app in which I've extended the Application class in order to hold some global variables. I initialize these global vars in my root Activity (the first screen that the user sees). My application contains a number of Activities…
Wise Shepherd
  • 2,228
  • 4
  • 31
  • 43
0
votes
1 answer

getWindow() from context Android

I don't know how to do .setParentLayout(getWindow().getDecorView()) I'm using a library in order to do Tutorial bubbles, and when a user makes a long click on a gridView's item the bubble appears. The problem is that I don't know how to put…
0
votes
2 answers

Android get context on a non-activity class that is result of a push message open

I'm developing and application that use OneSignal API to receive push messages. Below the code that handle open messages: Receiver public class OneSignalBroadcastReceiver extends BroadcastReceiver implements OneSignal.NotificationOpenedHandler { …
Juliano Oliveira
  • 868
  • 1
  • 9
  • 29
0
votes
1 answer

Which Context? To avoid Memory Leaks

I know this has been asked many times but still many new developers like me finds it difficult.To avoid memory leaks which context should be used?. Somewhere i found that we should getApplicationContext() and somewhere that try to use…
Sonali Pawar
  • 420
  • 3
  • 18
0
votes
0 answers

Android - Deleting Key Element from SharedPreferences

I'm using the following method to delete a key element on the SharedPreferences of my app. I'm calling it from within a fragment. The problem is that the element is never deleted from SharedPreferences and I get no LogCat output. Is there something…
CBA110
  • 1,072
  • 2
  • 18
  • 37
0
votes
1 answer

How to reference resource file in a service?

I have a service and I run a thread inside it. When I try to reference the strings.xml I receive "can't resolve symbol R", I am able to reference the same resources from another class in the application. Please let me know how can I reference…
Amrmsmb
  • 1
  • 27
  • 104
  • 226