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.

97 questions
1
vote
1 answer

Object not being added to ArrayList inside a Thread of Application class

I'm working with Kotlin in Android app development. This is the code I'm trying to run when the Application is instantiated class SpeechApp: Application() { var isDictionaryRead = false lateinit var wordslist : ArrayList
Sparker0i
  • 1,787
  • 4
  • 35
  • 60
1
vote
1 answer

How to prevent the Screentshot in the entire android app without repeating the same code

Hi everyone i want to block the Screenshot in my app. I got the first problem solve from here. But now the thing is I have more than 10 activity and 10 + fragment. Is there any way to do this just by writing in the one class and giving it reference…
Aakash
  • 101
  • 2
  • 11
1
vote
0 answers

Android Java Implement KEYCODE_VOLUME_UP and DOWN to my code

I wonder how to implement KEYCODE_VOLUME_UP and DOWN to my code. So every time when I press the volume up or down key will simultaneously reflect on my Notification Volume Control app. The method I want to implement is as follows which will make my…
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
  • 1,103
  • 1
  • 12
  • 26
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,305
  • 25
  • 30
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…
mob_web_dev
  • 2,342
  • 1
  • 20
  • 42
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
0 answers

Creating instance in Application class

I am developing an Android Application, in which I am using Network libraries Retroift with GSON,Otto and Realm. So am creating instance in application class( extends Application). It makes my app launching time very slow. Is there any alternate…
Raja Jawahar
  • 6,742
  • 9
  • 45
  • 56
1
vote
1 answer

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
  • 291
  • 2
  • 19
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

Establishing a network connection between 2 devices in android studio

I'm trying to set a connection between 2 devices. As a matter of fact, I'm writing a game application, and I want to run it on 2 devices. One of these devices is a virtual one, and the other one is my phone, a physical device. I need to run the…