title: How do I write data on a nfc tag in a fragments?
body: <p>My starting point was here <a href="https://github.com/rudsonlive/Navigation-Drawer-ActionBarCompat" rel="nofollow">https://github.com/rudsonlive/Navigation-Drawer-ActionBarCompat</a> implementing a new app with nfc writing support.</p>
  
  <p>Now I want to implement writing data on nfc tags. Therefor I am using different fragments for different kind of data (e.g. one fragment to write contact data on a nfc tag, the next fragment to write specific application data on a nfc tag, and so on).</p>
  
  <p>For another app I successfully implemented this, but for the setting up the app with fragments I fail.</p>
  
  <p>This is how I implemented tag writing within an activity. Showing an AlertDialog to inform the user to approach a tag and handling the specific intent.</p>
  
  <pre><code>enableTagWriteMode();
  AlertDialog.Builder ad = new AlertDialog.Builder(NfcDialogActivity.this).setTitle("Approach Tag").setOnCancelListener(
      new DialogInterface.OnCancelListener() {
          @Override
          public void onCancel(DialogInterface dialog) {
              disableTagWriteMode();
          }
      });
  alert = ad.create();
  alert.show();
  </code></pre>
  
  <hr>
  
  <pre><code>@Override
  protected void onNewIntent(Intent intent) {
      // Tag writing mode
      if (mWriteMode &amp;&amp; NfcAdapter.ACTION_TAG_DISCOVERED.equals(intent.getAction())) {
          Tag detectedTag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
          if (writeTag(mNdefMessage, detectedTag)) {
              Toast.makeText(this, "Writing complete", Toast.LENGTH_LONG).show();
              alert.cancel();
          } 
      }
  }
  </code></pre>
  
  <p>Could someone give me an advise how to write tags as mentioned above within a fragment?</p>
  
  <p>Thanks in advance &amp; sry for my english...</p>