Android :: Stop Mediaplayer From Previous Activity
Feb 16, 2010
Can anyone tell me how to stop media player that was started in a previous activity?For ex. In activity-1 button pressed that did - mp.start(); then activity-2 starts for different layout with new buttons, then when button pressed, mp.stop is called, but does not stop the media from the first activity.
View 4 Replies
Apr 27, 2010
How to finish any previous activity in application stack (at any level , I mean not immediate parent) , from current activity like on some particular event I want to invalidate this previous activity?
View 1 Replies
View Related
Nov 5, 2010
The default behavior from my observation is if current activity force closes Android tries to go to previous activity on stack How can I control this behavior? I want force close to close all activities
View 2 Replies
View Related
Dec 30, 2009
I am developing an application in which the user require to register first and than got the user page. For that i have made layout and the layout consist many fields, so, i have made part of layout and also made the separate activity for the each layout. The layout like address, phone, etc... After that i have wrote the code for calling an activity and it works fine. It means when i press the "Next" button the another page will come and it will also consist some textview ,edittext and previous and next button. Actually, i want something different like -- When the user fill the first form and he will proceed to next, the content written by the user should not gone when the user press "Next" button. The content should be there which was written by user. And same way i have have 6 pages like that way to complete the registration process. So, have you any idea to solve above problem? I really need your help because right now i stuck at this point. So, please any body help me out of this problem. I would appreciate your help. I am waiting for your reply.
View 15 Replies
View Related
Jul 21, 2009
I develop a music play app, whe app framework is:
list.java->play.java
eg: in the list.java there have two mp3 files : 1.mp3,2.mp3 when first time choose 1.mp3, then play ok, then back to list.java from play.java, and now the 1.mp3 is still playing, and then i click 2.mp3 in the list.java, and go to play.java, but it play 1.mp3 and 2.mp3 simultaneously? but i have used the mediaplayer.stop(); mediaplayer.release(); and it always play 1.mp3 and 2.mp3 simultaneously? i want stop 1.mp3 and play 2.mp3.
View 7 Replies
View Related
Sep 17, 2010
My android app creates a MediaPlayer() and plays a looping song. I need to have it stop playing when the user leaves the app. I also need to get at the volume buttons somehow, to let users adjust the songs volume...
CODE:..................
View 1 Replies
View Related
Jun 3, 2010
I'm playing around with the MediaPlayer class to reproduce some sounds/music. I am playing raw resources (res/raw) and it looks kind of easy.
To play a raw resource, the MediaPlayer has to be initialized like this:
CODE:.................
Until here there is no problem. The sound is played, and everything works fine. My problem appears when I want to add more options to my application. Specifically when I add the "Stop" button/option.
Basically, what I want to do is...when I press "Stop", the music stops. And when I press "Start", the song/sound starts over. (pretty basic!)
To stop the media player, you only have to call stop(). But to play the sound again, the media player has to be reseted and prepared.
CODE:...............
The problem is that the method setDataSource() only accepts as params a file path, Content Provider URI, streaming media URL path, or File Descriptor.
So, since this method doesn't accept a resource identifier, I don't know how to set the data source in order to call prepare(). In addition, I don't understand why you can't use a Resouce identifier to set the data source, but you can use a resource identifier when initializing the MediaPlayer.
I guess that I'm missing something. I wonder if I am mixing concepts, and the method stop() doesn't have to be called in the "Stop" button.
View 4 Replies
View Related
Aug 22, 2010
I see calling the stop function of MediaPlayer simply does nothing. The playback goes on.
I looked in the documentation and I found: "Stops playback after playback has been stopped or paused."
So, I tried to pause() it before stopping, but the MediaPlayer then pauses and resumes the playback. The only thing I can see is that the buffering stops. But the playback continues. Is this the expected behavior? Could the problem be related to the fact that I call the methods of the MediaPlayer object from different threads than the creator by synchronizing with Semaphores?
View 6 Replies
View Related
Nov 18, 2009
I have a activity which is called from another activity as an intent... This activity loads and starts playing a audio file. All is good - that much works. The activity also has a "stop" button and that stops the audio from playing - that is also fine.
But how do I stop the file from playing if the user uses the back button to leave the activity without clicking on the "Stop" button?
View 3 Replies
View Related
Jul 24, 2009
This is an intermittent bug in one of my apps. I don't expect anyone to solve it immediately, but I'd appreciate any thoughts on how to start debugging!So, my app lets users edit an item (in the EditPage activity). When they press the Back key, the desired behaviour is that it saves their edits and returns them to the home page (the HomeList activity). The code for this is below. It works fine. Except.The bug is this. Some users report that sometimes when they reopen the application after a pause, they are seeing *not* the home page, where they left the application - but the previous edit activity. Crucially, they are also seeing the edit activity without their saved edits - effectively losing their most recent edits.I've been able to reproduce this myself. It only happens after the application hasn't been opened for a while. If I save something, minimize the application and reopen it straight away, it shows the HomeList activity just fine, and the edits have all been saved. But if I save something, leave it for a couple of hours and then reopen it, it shows the previous EditPage activity, without the saved edits (i.e. in the state that the EditPage activity was previously launched).
Any ideas, anyone? I had wondered whether it was due to the Back button being used to return the user to the HomeList activity - maybe Android thinks that the Back button means that the HomeList is not the most "recent" activity, instead the EditPage is. I'd like to carry on using the Back button if possible, though. And in particular, I'm puzzled why it only happens after the app has been idle for an hour or so, and not immediately? Is it something to do with Android's memory management?
View 4 Replies
View Related
Jun 2, 2010
I need a way to detect if this is the first time the user is ever opening the application, if so, start an activity. Then all previous application launches wouldn't start that activity. I've read in a few places about using preferences to accomplish this. Anyone got any ideas?
View 2 Replies
View Related
Dec 16, 2009
How to store previous activity value in android
View 2 Replies
View Related
Jul 14, 2009
Can any one tell me how to pass the value from one screen to its previous screen. Consider the case.i m having two screen first screen with one Textview and button and the second activity have one edittext and button. If i click the first button then it has to move to second activity and here user has to type something in the textbox. If he press the button from the second screen then the values from the textbox should move to the first activity and that should be displayed in the first activity textview.
View 4 Replies
View Related
Jul 4, 2010
I have two activities. The first is a list where the user selects one of the items which takes them to a second activity showing the details of the item they selected. When the user clicks the back button I want the app to return to the first activity.
Is there anything special i need to do to make this happen?
Right now when I click the back button from the second activity it exits the app just like the home button would.
Here is how I am starting the Second Activity. startActivity(new Intent(getApplication(), SecondActivity.class)); finish();
View 3 Replies
View Related
Oct 31, 2010
I'm writing a bitmap editor and I'm trying to write an autosave feature. When onPause is called, I write the application state to an autosave file. As this takes between 0.1s and 1.5s, I've been advised this IO operation be performed in a background thread.
In the onCreate method of my activity, I check to see if the autosave file exists and, if it does, I open it.
Are there any scenarios I have to consider where the user can somehow leave the activity, the autosave thread starts and the user can return to the activity before the thread has finished? If so, how can I detect this and wait for the thread to finish before I check the state of the autosave file?
I was going to make it that, when the user backs out of my activity, they're asked to wait a second while the data is saved. This seems OK, but I can't do this when my activity is interrupted by something like a phone call.
Also, I'm a bit confused about how multiple versions of the same activity can be started as this makes dealing with autosaving more complex. Is there a way to make sure only one instance of my activity is allowed to run at a time?
View 2 Replies
View Related
Aug 26, 2010
how to get font from the previous activity on current activity on canvas
View 1 Replies
View Related
Apr 20, 2010
I am using an Application object to store app-wide instance data--data that I need to remain in existence for the entire lifetime of the app, so the Application class seems like the proper place to put it. I have just finished reading this thread http://groups.google.com/group/android-developers/browse_thread/threa... that goes into pretty good detail and receives confirmation from Googler hackbod as to how the Application class performs--and from that info it seems this strange behavior I am receiving should not be happening...
Basically, every once in a while when I resume my app in any of its Activities (it is still running in memory so onCreate is not called) I get NullPointerExceptions because instance variables in my Application class are returning null when I request them from my Activity (via a getter method in my custom Application class). It seems as if sometimes Android saves the states of my Activities but deletes all my instance variable data... This can't be an Android problem--there must be something wrong with my code.
Has anyone else ever ran into an issue of this kind? Any ideas as to what may be causing this? I'm not going to post my code here as that won't help anyone, but hopefully someone can point me in some helpful directions.
View 11 Replies
View Related
Apr 21, 2010
I'm writing an application consisting of several activities and, on restarts, I'd like the application to initially display the application's activity that was the last to display in the application's previous session.
I save information about the last activity in SharedPreferences and I'm trying to start that last activity with a call to startActivity(intent) from my Application's onCreate handler.
The problem is that if I don't set the intent's FLAG_ACTIVITY_NEW_TASK, the result is a run-time exception message in logcat suggesting that I should set the flag. And if I set that intent flag, the correct activity gets started but doesn't fully initialize resulting in null pointer exceptions (which don't occur when I don't attempt to start the activity from my Application class).
CODE:...........
Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
How to correctly start a particular activity from the Application class's onCreate handler?
View 3 Replies
View Related
Feb 1, 2009
I'm using a mediaplayer to play a sound file, when you leave the application the sound continues in the background, which is the desired behaviour.
However, when the app is resumed, the mediaplayer isn't retrieved, so hitting pause just starts a new player so now there are two sounds playing.
Is the mediaplayer a type of service? How can I access the original player again?
View 3 Replies
View Related
Jul 15, 2010
When i leave my app after pressing home button and then re launch it from menus it behaves in a strange way.Sometimes it launches the same activity on which i pressed home button.But sometimes it launches the first activity of my app. One reason for this could be that whenever system has memory shortage it clears any activities existing in But the strange thing is if i press back button from first activity it takes me back to the same activity on which i pressed home button and all other previous activities are also there(like if i press back button again previous activities also exist.)I haven't set any launching mode for any activity in my app(like single instance etc).What i don't need is that previous activities load on pressing back button on first activity.
View 2 Replies
View Related
Oct 26, 2009
I have an android application with a LOT of activities, think of something like a book where every page is a new activity. The user can make changes in each activity, for example highlight certain texts with different colored markers etc. and it's crucial that I'll remember this information as long as the application stays alive (and I don't want/need to remember any of this when it's not). As I understand the best mechanism for storing this kind of information is via onSaveInstanceState(Bundle outState) and onCreate(Bundle)/onRestoreInstanceState(Bundle) rather than lets say, the Preferences mechanism. My only problem is that the user can navigate backwards to previous pages (Activities) and the only way i know of achieving this is by calling finish() which of course kills the current activity without calling onSaveInstanceState(Bundle outState) and even if it did call it, the next time I would launch an activity representing that page it would be an entirely new instance. So my question is: Is there a way to go back to the previous activity without calling finish()? or, is there a better way to save this information? maybe through static variables?
View 1 Replies
View Related
Apr 27, 2009
I have a requirement to play several sounds many times in my game so instead of creating the MediaPlayer again and again I have called mp.seekTo(0) in onCompletion(mp) so that it will restart. Sometimes the sound is not audible from the device when I call mp.start () after setting mp.seekTo(0); but the player calls onCompletion() without playing any sound, this is observed randomly on most of the sounds
My sounds are of short duration mostly less than a second.
I am using a separate MediaPlayer for each sound (as I need this) -
There are almost 28 sounds in my game so i will be creating 28 MediaPlayers.
Below is the attached code for player
Also If I try to play many sounds one after the other in a short period of time i get an error saying "no more track names available". can u tell Why this is happening...?
check the below code:
CODE:........
View 9 Replies
View Related
Jul 28, 2010
I had a prob with app i.e when i am moving to the previous window the control goes to the splash screen of my app because the previous activity is killed by android runtime. how to make the previous activity alive. or how to create activity again and how to access it from present activity.
View 2 Replies
View Related
Feb 16, 2009
I have one Activity, that starts one Service and my service will lunch one Activity, i wanna to stop the Activity which one started my my Service after few seconds. Is there any way to achieve. Has anyone experienced this type of scenario.
View 5 Replies
View Related
Mar 19, 2010
My application contains three-four pages.On click of button in first page,I start a new activity which redirects to another page and second page redirects to third page and so on.Now I want to include one button which On click will redirect to first page by stopping all activities. So how to achieve that?
View 5 Replies
View Related
Aug 3, 2010
I want dont want the activity animation that comes by default when we start a new activity (i.e. the right to left scrolling effect to new activity view) so i googled a bit and found a flag FLAG_ACTIVITY_NO_ANIMATION in the Intent class also i applied that flag to my intent via the setflags() method but somehow i still see the activity animation when a new actvity is launced ( i am developing in android 2.1 update).
View 6 Replies
View Related
Dec 9, 2009
My problem is: Activity A called Activity B, and in Activity B, it start a background thread to do some client-server work. But it maybe takes too much time. So i add a cancel button to call the stop() method to stop the thread, and call finish() to finish the Activity B and go back to Activity A. Although it is back to Activity A, the thread isn't stop immediately. Can i just call the finish() to go back to Activity A, and leave the thread to exit by itself? If it is not the right way, which is?
View 10 Replies
View Related
Feb 10, 2009
I have an Activity which gives me the following stack trace error and it looks to be out of my control (I could be wrong though as I'm a newb to Android).Can anyone point me in the right direction? (It happened when I clicked on the back button)
View 2 Replies
View Related
Aug 12, 2010
I have a START and STOP button in the main screen of an App. there are some GUI and threads that are instantiated when I click on START. When I click on stop, I want everything to be stopped and the activity should come back to its origin state. To the state that is exactly same like when launched (when we tapped on App icon in mobile).Is it possible to do this? I tried with finish() , this killed the app and exited . I don't want to exit from main screen. rather, on clicking STOP I want app to come back to origin or born state.
View 2 Replies
View Related
Dec 7, 2009
I would like to know if there is a way to stop activity destruction upon physical keyboard slide in/out event.
View 4 Replies
View Related