Questions tagged [android-application-class]

Extending Android's Application class can be very useful to maintain global state, initialise a module, and so on, before any other part of your code runs.

Android Developer Docs say:

Base class for maintaining global application state. You can provide your own implementation by creating a subclass and specifying the fully-qualified name of this subclass as the "android:name" attribute in your AndroidManifest.xml's <application> tag. The Application class, or your subclass of the Application class, is instantiated before any other class when the process for your application/package is created.

91 questions
1
vote
1 answer

Can a fragment be created from an extension of the Application class?

I have a background task that occasionally prompts the user with dialogs and I would like it to run through the life of the application. Right now everything is controlled from a task fragment. So I was wondering if it is possible to create this…
David Carek
  • 995
  • 1
  • 9
  • 25
1
vote
3 answers

Displaying a Toast message from the UncaughtExceptionHandler

I am trying to show a Toast message from a class which is a customExceptionHandler. But I am unable to do that. I have seen the similar issue like Displaying a Toast message from the Application class But still, it didn't solve my issue. Is…
Raghavendra
  • 2,230
  • 20
  • 28
1
vote
1 answer

NotificationListenerService called before Application.onCreate code

I have a NotificationListenerService implementation in my app. It seems that certain things that I initialize in my Application class are not initialized when my NotificationListenerService runs. Also, crashes are not coming into Crashlytics, but…
1
vote
0 answers

Global Variables and DarkMode

I am trying to make a Global Variable to make a dark mode for my entire app. But it seems that its not working. I already followed the guide to make a Global Variable. Here is what I have so far: GolobalVariables appState; appState =…
1
vote
1 answer

Application onCreate not called when Notification Access Enabled

My Application onCreate is not calling when the notification access enabled.It calls only when I update the app or When I disable the notification access of my app.Here are the scenarios I found by debugging the app. Condition 1 - onCreate Not…
Debugger
  • 2,123
  • 1
  • 17
  • 39
1
vote
0 answers

lifetime of static Application variables - android

I defined a static variable in my custom Application class. Something like this: public class App extends Application{ ... public static Object var; ... @Override public void onCreate() { var = new Object(); …
1
vote
1 answer

ContentProvider not called onCreate after deleting database

I have created ContentProvider which creates one Database on application launching. Now In that application, I am doing process of deleting database when user logout from app. After that when I come again to login, the ContentProvider cant call…
1
vote
1 answer

Android gridview onItemClickListener to set activity background image

I'm pretty much stuck with my android app... I am trying to make a gridview with images and use OnItemClickListener() to set an image as background. THE PROBLEM I HAVE IS... When i set the image as background it disappears when the activity is…
1
vote
1 answer

Stop intent from beeing executed - in application subclass

Under some conditions, my application gets started by calling one of my Broadcast-Receivers or Services (etc), but I want to prevent the component that is used for the intent to get started. Why: Because I need to do some prior initialization…
1
vote
2 answers

Is it possible to call method in Activity class from Application class?

I have defined a public method in Activity class (lets say some_method()).Is it possible to call this method in Application class.
Durgesh
  • 281
  • 2
  • 18
1
vote
1 answer

Application subclass implements the required interface but system says no

I am trying to use Twilio to verify user when he first signs up, by sending SMS to the phone number that he entered. I get following error in LogCat, although my Application subclass implements LockProvider: Android Application object must implement…
or am-shalem
  • 47
  • 1
  • 10
0
votes
0 answers

What happens to the application when it's closed via the multitasking menu

How do services/activities behave? Do I get any lifecycle events? Also what's the difference when swiping the application away via the multitasking menu and force stopping it from the settings?
noev
  • 878
  • 7
  • 23
0
votes
0 answers

add data to listview from another activity

I'm really confused on how to add from another activity I keep getting an error in this part of the code: Emails a = new Emails(intent.getStringExtra("inputEmail"), intent.getStringExtra("inputBody"), intent.getStringExtra("inputSubject")); So the…
0
votes
1 answer

App stops Caused by Attempt to invoke interface method 'int java.util.List.size()' on a null object reference

How to Fix this code? It keeps closing the app for these reasons in logcat? Error that I got is in here It keeps on crashing or stopping everytime i run it. I do not have build errors but i checked my logcat for the reason and still cant resolve…
0
votes
0 answers

android.content.res.Resources android.content.Context.getResources() null problem

I created Util for accessing resources simpler than before. It gets resource from MyApplication or from the context. However, I get null object reference error and the resource id is, 2020-11-06 13:59:36.665 12563-12563/com.example.sample D/test:…