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

Making Application Context Globally Available - Good/Bad Idea?

I find throughout my code I often require access to the Application Context. Instead of passing Context around everywhere, I have it globally available via the following Application Class Extension: public class App extends Application { static…
Mtl Dev
  • 1,604
  • 20
  • 29
0
votes
0 answers

How to get another app's context in android?

Is it possible to get another application's context if I have the Package-Name? I need to get application's context anyhow... Please answer if any one know..
Muhammad Jobayer
  • 157
  • 1
  • 10
0
votes
2 answers

getApplicationContext() as a activity to excute runOnUiThread()?

((Activity)getApplicationContext()).runOnUiThread(new Runnable() { @Override public void run() { } }); This code is right? I get a trouble to think it!
zys
  • 1,306
  • 3
  • 18
  • 37
0
votes
1 answer

How to Start android service without activity

I created an application that contain a Service that start from button click of Activity. But I want to create a new application that doing the same as the last one - but don't have any GUI interface => that mean without any Activity. I want to…
Yanshof
  • 9,659
  • 21
  • 95
  • 195
0
votes
1 answer

Launching service from class without a Context

I'm trying to figure out how to launch a Service from a singleton class I've created. According to the Android documentation, startService is a method of Context. So, in the method call I am making to the singleton class, I figured I would pass on…
Andrew
  • 20,756
  • 32
  • 99
  • 177
0
votes
0 answers

Get a Service context from a normal class

I have three classes: MyPlugin extends OtherPluginClass extends Service MyService extends AccesibilityService LoggerClass implements BaseLoggerClass MyService starts when the user authorizes it in Accessibility settings. MyPlugin is started and…
Julio Vga
  • 143
  • 1
  • 7
0
votes
2 answers

View and Activity how to share data in android.content.Context?

I want MyView can share data with MyActivity, so I need they can put data into Context and get data from Context, How to do that? class MyView extends Button { public MyView(Context context, AttributeSet attrs) { super(context,…
lionyu
  • 593
  • 3
  • 5
  • 14
0
votes
1 answer

new DialogInterface.OnClickListener doesn't work in fragment

I have an AppCompatActivity with fragment. Inside fragment I have an ImageButton. On a click on that button I want to show a dialog with all the needed Intents in system. Fragment relevant code: avatar.setOnClickListener(new View.OnClickListener()…
0
votes
1 answer

Modify string values before display in android

I need to make some modification to the strings defined in strings.xml before displaying it to the View. I am able to extend Resources class and override the getString() function to return the modified string. public class MyResource extends…
0
votes
1 answer

Getting resources when fragment is no longer attached

What's the recommended way of accessing app's resources in a situation where the fragment may or may not be attached to the activity? The reason I'm asking it's causing crashes when the asynchronous bit of code is getting executed while, for a…
wtk
  • 1,033
  • 10
  • 15
0
votes
1 answer

Getting Application Context in Different Package

I have to access the Context in different package. The thing which I am achieving is that I want to save a Integer value in Preferences and want to get the value in different package. Is there any way to achieve this? Actually, there is an…
0
votes
1 answer

Activity leaked info + Progress Dialogue + Android

In my activity I did not use any asynctask. The purpose of the activity is to load data from api to sqlite database. Thus I used LoadData() on oncreate() of my activity. I want to implement progress dialogue while loading data that means time to…
0
votes
0 answers

Is Context.OpenFileOutput() and Context.OpenFileInput() reliable in android?

I have an app to create collages with a feature to apply filters on individual photos. To keep the app memory efficient and fast while applying filters, I simply store a copy of original photo(cropped version) in the Context, using…
The Coder
  • 121
  • 1
  • 7
0
votes
3 answers

NullPointerException on getBaseContext()

I have a MainActivity class that has a method called: updateTabTitles(); updateTabTitles() does what it sounds like, updates the titles of my tabs. String tabName = tabNames[tabNumber]; String font = "helveticaneuebold.ttf"; // Fonts found…
Brejuro
  • 3,421
  • 8
  • 34
  • 61
0
votes
1 answer

How to get an ApplicationContext from createPackageContext()

The code is followed: Context c = getContext().createPackageContext("com.master.schedule", Context.CONTEXT_INCLUDE_CODE|Context.CONTEXT_IGNORE_SECURITY); int id = c.getResources().getIdentifier("layout_main", "layout","com.master.schedule"); …
JoeKevin
  • 81
  • 3
  • 12