نوشته شده توسط
spiderman200700
در تصحیح این پست:
البته چون کلاس Application هم ذاتا یک سرویسه، میتونید آهنگ رو در این کلاس هم اجرا و قطع کنید که نسبت به ایجاد کردن سرویس کار کمتری میبره. البته یک سری محدودیت های ماندگاری در حافظه داره که در مورد شما فکر نمی کنم مشکلی ایجاد کنه.
این اشتباه هستش. این کلاس یک کلاس پایه برای وضعیتهای مختلف اپلیکیشن هستش که به صورت سراسری تعریفی که شده رو نگه داری میکنه و همه جای برنامه میتونید بهش رفرنس بدید
/**
* 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 <code>"android:name"</code> attribute in your
* AndroidManifest.xml's <code><application></code> 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.
*
* <p class="note"><strong>Note: </strong>There is normally no need to subclass
* Application. In most situations, static singletons can provide the same
* functionality in a more modular way. If your singleton needs a global
* context (for example to register broadcast receivers), include
* {@link android.content.Context#getApplicationContext() Context.getApplicationContext()}
* as a {@link android.content.Context} argument when invoking your singleton's
* <code>getInstance()</code> method.
* </p>
*/