I am developing an android music player app and i noticed that when i press the home button and open the app again it takes me to a new instance of the main activity, even when the music is playing.
My question is, is there any way i can prevent this from happening? I want to make it so that when pressing the application icon after it is already open, the first instance of the main activity is reopened without reloading?
I tried changing the launchMode on the manifest, as it says here:
http://developer.android.com/guide/topics/manifest/activity-element.html
Many thanks :)
Related
Hi i need something to don't let users exit my app without pressing the button exit. Basicly if they use home or any other button the app can't exit. How can i make this? Im using android studio and im new to this language.
The only thing you can do is override the onBackPressed method but unfortunately, you can't stop the home button from closing the app unless the phone is rooted or something. But when you do close the app with the home button it is still in Android's memory which prevents cold starts the next time the user opens the app. I am not sure why the information would be helpful though.
In an android App im showing advertisement from a local advertisement company.
My problem is when start App and close it with back button, and back to it by clicking on its icon, i see the same Ad. But when i close the app from android task manager and back to the app, i see another Ad.
I know this can have multiple reasons and my question is not clear, But my main questions that how i can set each activity runs like first time of running the app? What should cause this reaction? its like a cookie system... i want every activity show new Ad!
Here you can see example code:
http://github.com/adad-project/client-app-sample
Move
Adad.initialize(getApplicationContext());
((AdView) findViewById(R.id.banner_ad_view)).setAdListener(mAdListener);
to onStart and remove from onCreate in MainActivity
Do similar thing in other activities.
I am currently writing an Android app to work as an activity launcher.
The main activity works as launcher and will let users launches a new activity from the main activity(here I create this new activity using FLAG_ACTIVITY_NEW_TASK and FLAG_ACTIVITY_MULTIPLE_TASKS).
So that I can hold multiple these activities with the same name but different content in the background.
But I still need a method to manage them, which means I can offer a UI for user to choose to restart one and kill one.
Can someone give me a good solution?
I appreciate your help very much!
And you can also view a similar question asked by me yesterday: set unique identifier for RunningTaskInfo
You need to get the list of Activity instances which are running in your application. List of all of the activities in our application that are running on the device gives an answer how to do this.
I have created an Android app that I am also running on BB10 devices. It has some functionality regarding call logs, but one of the most important functions is that the app has to open (assuming it's in the background currently) whenever a phone call has ended. Worded differently, it needs to foreground itself whenever a phone call has ended. I currently have it creating a dialog that opens within the app, but it will not appear until the app has been manually foregrounded. I do not have a requirement as to how it opens itself, but I do need a yes / no dialog to appear when it does.
Is there any way to have the app auto-open itself? Or is that not possible?
This must be an easy one but I'm not having much luck searching for an answer.
Apologies if this is a regular question.
If I navigate away from my app I cannot return to it. Starting the app again will load a second instance of it rather than returning to it. If I leave an audio loop running in my app, It's hard to get back in and turn it off.
On startup I'd like the app to destroy any previous instance of itself left running.
I'd also like to try having the app shut itself down when I navigate away (I know it's not the right way to do things but I'd like to try this for my own personal use of the app). Or have the "back" button destroy the app.
Thanks.
Add this to your activity definition in manifest...
android:launchMode = "singleInstance"
How to prevent the activity from loading twice on pressing the button
I have answered such a question,you can declare android:launchMode="singleTask" attribute for your MainActivity in the AndroidManifest.xml file, so that the OS won't create a new instance if there is one running in the background.