I am trying to print a .txt file that saves my application through FileWriter.
The file it saves is / sdcard / StudentLatePass.txt
When you press the print button, the SD file is saved and then it needs to be printed. I am following the Google Cloud Printing Tutorial .
package com.android.upgrayeddapps.latepass; import java.io.File; import java.io.FileOutputStream; import java.io.OutputStreamWriter; import android.app.Activity; import android.app.AlertDialog; import android.content.Context; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.widget.EditText; import android.widget.Button; import android.widget.Toast; public class StudentActivity extends Activity { EditText txtData; Button btnPrintTardy; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.student);
Over the course of my life, I tried to change docUri, docMimeType, and docTitle to everything under the sun to print this file.
My current modified code
btnPrintTardy.setOnClickListener(new OnClickListener() { public void onClick(View v) { //Print using Google Cloud Print Intent printIntent = new Intent(this, PrintDialogActivity.class); printIntent.setDataAndType(docUri, "text/plain"); printIntent.putExtra("title", "Student Late Pass"); startActivity(printIntent); }// onClick });// btnPrintSDFile
I still get red squigglies under docUri, and when I pass the print intent
source share