1. Android Central Question's Avatar
    How to start a Chronometer when a DialogFragment is clicked (its OK button)? I have something like the following, but it gives null object reference error. I want the timer to start only after the user clicks the ok button in the dialogFragment.
    Code:
    public class A extends AppCompatActivity {
    private Chronometer mChronometer;
     @override
       protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
           setContentView(R.layout.activity);
           mChronometer = findViewById(R.id.chronometer);
           mChronometer.setBase(SystemClock.elapsedRealtime());
    }
    public void startTimer(){
      // This method is start using Fragment.
       mChronometer.start();
    }
    }
    07-18-2019 04:11 PM
  2. B. Diddy's Avatar
    I moved this to the Software Development forum for more specific traffic.
    07-18-2019 04:36 PM
  3. Rukbat's Avatar
    Take a look at https://abhiandroid.com/ui/chronometer Maybe you can use some of the code there - or see what you're missing.
    07-18-2019 05:03 PM
  4. Changbroot's Avatar
    Take a look at https://abhiandroid.com/ui/chronometer Maybe you can use some of the code there - or see what you're missing.
    Thanks, but I already looked at that and can't help me out. All I want is to start the damn Chronometer using a DialogFragment. It doesn't have to be directly using the fragment, but it must be started after the fragment is gone.
    07-19-2019 04:16 PM

Similar Threads

  1. How to get 'Usage Manager' app back in Galaxy S7 Active ?=(
    By Android Central Question in forum Samsung Galaxy S7 Active
    Replies: 32
    Last Post: 07-19-2019, 11:57 PM
  2. Huawei P Smart Sending tones to my home phone during call?
    By Android Central Question in forum Ask a Question
    Replies: 1
    Last Post: 07-18-2019, 02:44 PM
  3. How can I get rid of the white around my apps?
    By Android Central Question in forum Ask a Question
    Replies: 6
    Last Post: 07-18-2019, 02:23 PM
  4. how can i stop repeting text messages in honor 7s
    By Android Central Question in forum Ask a Question
    Replies: 1
    Last Post: 07-18-2019, 12:49 PM
LINK TO POST COPIED TO CLIPBOARD