FAQ Database Discussion Community


How to do onBackPress dialog in fragment in android?

android,android-fragments,android-lifecycle,android-event,onbackpressed
I was working on create a dialog that pop up to confirm whether the user exit the page. In the past I used the activity so it has no problem. I just need to put the dialog inside the override onBackPress function, and call finish() if the user choose to...

how to copy back button action to another button

android,back,onbackpressed
I have a button in which I want to have the same feature of the usual BACK button. But just calling the finish() is not doing the required. I tried calling onBackPressed() but it needs to create a separate method. Any solution? t1.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0)...

Android reverse shared element transition on back after orientation change?

android,material-design,recyclerview,onbackpressed,shared-element-transition
For shared element transition I am following this github project. It has 2 screens - one with recyclerview having number of cards & second the detail screen. As expected, it exhibits shared element transition of imageview & textview from recyclerview item to detail screen & reverse transition on back press....

Android MediaPlayer stops on backpressed

android,media-player,android-mediaplayer,back,onbackpressed
I'm developing a radio stream app.I use android - mediaplayer class which plays radiostream. I m trying to run app in two devices . When I pressed back button in Samsung galaxy S3 mini(4.2.2) radio stream continues to playing. And I controls media player with notification bar. But when I...

How get back to previous activity by onBackPressed() and use new theme?

android,android-intent,themes,preferenceactivity,onbackpressed
i have an app with 3 activities:main,second,preferences. i can call preferences from main and second one.for preferences i used PreferenceActivity. i my preferences i want to change theme. but the problem is that the theme changed only when activity onCreate.. and when after changes in preferences i press BackBTN, it...

how to change behaviour back button in android

android,back-button,onbackpressed,back-button-control
My app includes tts and stt. My app works by voice command. So, I want to use the back button. When the user click back button, the app should go to the first step, but it didn't. My code; public class SpeechActivity extends FragmentActivity implements Const { protected PowerManager.WakeLock mWakeLock;...

On back press, coming back to RecyclerView having Fragments causes IllegalArgumentException

android,android-fragments,android-viewpager,recyclerview,onbackpressed
I am having 2 fragments in activity. First fragment A has a recyclerview where one of the rows contains viewpager. This ViewPager has number of fragments (each page is a fragment) created using FragmentStatePagerAdapter. Now clicking on an action item I am navigating user to fragment B. Here I am...

Unable to start activity ComponentInfo Parse

java,android,parse.com,onbackpressed
I'm developing an app that uses Parse to store and retrieve some data. I followed the setup guide on the website but it´s crashing! These are the files: MainActivity.java: package apps.XXXXXX.test; import android.os.Bundle; import android.support.v7.app.ActionBarActivity; import android.view.Menu; import android.view.MenuItem; import com.parse.Parse; public class MainActivity extends ActionBarActivity { @Override protected void...

Stop sound file when back pressed in Android

android,media-player,onbackpressed
I have some audio files in listview which I play them randomly. while the file is playing I want to go back by pressing the back button, so in method onBackpressed I put the following if(mMediaPlayer.isPlaying()) { mMediaPlayer.release(); mMediaPlayer = null; }else { //show a message or something } but...