Eidenai
Eidenai

Reputation: 441

Android App Closes [Not Crashing] When Opening Another App

When switching from the app I'm working on to something that uses large amounts of memory (in this case, Pandora) - the application closes. It doesn't throw any errors, adb simply lists it as dead. I notice the same thing actually happens to Pandora. Meaning, if I spend to much time outside of Pandora or accumulate too much data then Pandora will also close. This leads me to believe that it's a function of Android, as if it's clearing its own RAM to accommodate the other applications. I was wondering if anyone could provide some more in-depth information on what's happening as well as if it's possible to make an application persist past this?

Upvotes: 3

Views: 1131

Answers (2)

Sher Alam
Sher Alam

Reputation: 372

I suggest you to use Service for background operations. A Service will be running in the background even if your activity is closed. You can connect later to the running Service by opening your activity and use bind method.

class DemoService extends Service {
@Override
public void onCreate() {
    super.onCreate();
}

@Override
public IBinder onBind(Intent intent) {
    return binder;
}
}

In your activity you can write the following code to start the service.

startService(new Intent(this, DemoService.class); 

Upvotes: 2

Urvish Modi
Urvish Modi

Reputation: 1138

If your background application closes, while you are long time working on other application is the default android life cycle. If any application remain unhandled long time its restarted. For your second question, If you are running Pandora with large memory on simulator you should extend memory of simulator. That you can give while creating AVD.

Upvotes: 1

Related Questions