Code example for DialogFragment

Methods: getActivity, getArguments, onStart

0
    return b.create();
  } 
 
  @Override 
  public void onStart() { 
    super.onStart(); 
 
    if(IS_NFC_SUPPORTED && getArguments().getBoolean("isNfc")) {
      startNfc(getArguments().getString("data"));
    } 
  } 
 
  @Override 
  public void onStop() { 
    super.onStop(); 
 
    if(IS_NFC_SUPPORTED) {
      stopNfc(); 
    } 
 
    mStatusCheckTimer.cancel();
  } 
 
  @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
  private void startNfc(String uri) {
 
    if(getActivity() != null && NfcAdapter.getDefaultAdapter(getActivity()) != null) {
 
      NdefMessage message = new NdefMessage(new NdefRecord[] { NdefRecord.createUri(uri) });
      NfcAdapter.getDefaultAdapter(getActivity()).setNdefPushMessage(message, getActivity());
    } 
  } 
 
  @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
  private void stopNfc() {