I want to keep the state of some objects and that these objects would be available everywhere.
Created such a class.
package com.uilmorcraft.uilmorlibrary; public class App extends Application { @Override public void onCreate() { super.onCreate(); Log.v("APPLICATION", "onCreate()"); } } In the manifesto prescribed as follows.
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.uilmorcraft.uilmorlibrary"> <uses-feature android:name="android.hardware.location.network " /> <uses-feature android:name="android.hardware.location.gps" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-feature android:glEsVersion="0x00020000" android:required="true" /> <application android:name=".App" android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppTheme"> ... </application> </manifest> Logically, onCreate should be called at least once. But nothing happens. Yes, put a breakpoint.
I tried to change the manifest so
<application android:name="com.uilmorcraft.uilmorlibrary.App" or so
<application android:name="App" effect zero.
Created a new application. I did the same thing about the miracle. Everything is working.
The project is large and somehow hard to transfer all the code from the old to the new project for the sake of the working class Application. But I think that after the transfer I can get the same thing.
Can anyone come across this?
InstantRun. Try to disable it in the studio settings - YuriySPb ♦InstantRunignored the changes in the manifest. The answer is written in more detail. In order not to stumble in the future on other limitations of this function - just turn it off. It is not worth using it - Yuriy SPb ♦