1

I am new to volley.I have two classes,AppController Singleton class, and ImageController Singleton class.But in Manifest,it allows only one application name.So how do I solve this?

hemen
  • 1,460
  • 2
  • 16
  • 35
  • 1
    You can see here [enter link description here](http://stackoverflow.com/questions/32677954/multiple-application-androidname-in-android-manifest) –  May 26 '16 at 07:29
  • Ron,I saw that but didn't understand.Thanks – hemen May 26 '16 at 07:30
  • 1
    marge two class in one class no need to create two different Application – Ashwini Bhat May 26 '16 at 07:30
  • I don't see the problem. One application can consist of several classes. Do you have some actual problem with running the app or are you just wondering about in on theoretical level? People are now making (possibly wrong) assumptions about your code and are possibly just confusing you even more with suggestions like lumping all together to one class/implementing this/extending that and whatnot without even having seen your code. Add some more details, so people can give more educated advice. – Markus Kauppinen May 26 '16 at 09:38

4 Answers4

3

You can try this way:

Application Class no one:

public class MyApplication extends Application {
}

Application class no two:

public class MyApplication2 extends MyApplication  {
}

In your Manifest:

<application
    android:name=".MyApplication2"
    android:allowBackup="false"
    android:icon="@drawable/app_icon"
    android:label="@string/app_name"
    android:supportsRtl="true"/>
Satan Pandeya
  • 3,747
  • 4
  • 27
  • 53
Rashed Zzaman
  • 123
  • 12
2

Only the <manifest> and <application> elements are required, they each must be present and can occur only once

According to documentation manifest file with only one application element is valid.

Try to Marge in Single Application Class

Naveen Tamrakar
  • 3,349
  • 1
  • 19
  • 28
1

First of all, every application should have only one application class that is the concept of MVC in android. You should remove one application class and do whatever it is doing in another one. As per your requirement: you have AppController and ImageController application class then remove all the code of ImageController application and merge it in AppController application class. Now use AppController class in manifest.

Rahul
  • 31
  • 4
0

I'm guessing you are using a Singleton as to have a class that holds your App data for the current session and\or another one for specific stuff (e.g. networking), if so, you have a couple ways of going about that:

  1. Use ONE Application class - you shouldn't have more than one, if so - merge them.

  2. If you insist on having 2 Singleton classes because you want to separate some functionality, you may create 2 Singleton classes, which are NOT your application class.

If you choose option 2, you should initialize(and maybe also control) them from your application class, especially to avoid duplicating a context object (that might lead to a memory leak), but make sure it's really necessary first.

since you tagged your question with the Volley tag, I'm guessing this SO thread about isolating Volley requests might help.

Hope anything here helped!

Community
  • 1
  • 1
TommySM
  • 3,793
  • 3
  • 24
  • 36
  • will it work !! if i extend eg:AppController extends Application extends ImageController ? – hemen May 26 '16 at 08:00
  • it might, but I would be careful about letting my Application extend other stuff, Application classes are soft spots for memory leaks, make sure you don't have redundant stuff in there, and if what you need in ImageController is the application context, I would separate it, have a look at the link I added, it might make things clearer, the example there is for networking with Volley but the pattern will work for other stuff too. – TommySM May 26 '16 at 08:05