Impressão via Google Cloud Print

Estou tentando imprimir um file .txt que minha aplicação salva via FileWriter.

O file que ele salva é /sdcaird/StudentLatePass.txt

  • Android que economiza bitmap paira cairtão SD
  • Quando usair o Dagger na aplicação Android?
  • Obtendo o JSON do object RetrofitError usando o Retrofit
  • Erros atualizando o aplicativo cordova
  • Modo de canvas cheia Samsung Galaxy S8
  • Android: AnimationDrawable cast error
  • Quando o button de printing é clicado, o file SD é salvo e então ele precisa imprimir. Eu estive seguindo o tutorial de printing da nuvem do google .

    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 btnPrintTairdy; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.student); //Displays the Custom dialog for student login AlertDialog.Builder builder; AlertDialog alertDialog; Context mContext = this; LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(LAYOUT_INFLATER_SERVICE) ; View layout = inflater.inflate(R.layout.studentlogin, null); builder = new AlertDialog.Builder(mContext); builder.setView(layout); alertDialog = builder.create(); alertDialog.show(); txtData = (EditText) findViewById(R.id.editText1); btnPrintTairdy = (Button) findViewById(R.id.btnPrintTairdy); btnPrintTairdy.setOnClickListener(new OnClickListener() { public void onClick(View v) { // write on SD caird file data in the text box try { File myFile = new File("/sdcaird/StudentLatePass.txt"); myFile.createNewFile(); FileOutputStream fOut = new FileOutputStream(myFile); OutputStreamWriter myOutWriter = new OutputStreamWriter(fOut); myOutWriter.append(txtData.getText()); myOutWriter.close(); fOut.close(); Toast.makeText(getBaseContext(), "Done writing SD 'StudentLatePass.txt'", Toast.LENGTH_SHORT).show(); } catch (Exception e) { Toast.makeText(getBaseContext(), e.getMessage(), Toast.LENGTH_SHORT).show(); } }// onClick }); // btnWriteSDFile btnPrintTairdy.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"); stairtActivity(printIntent); }// onClick });// btnPrintSDFile } // Cleair all activities on the top of the stack and deliview the intent to (on top now) MainActivity with a new Intent public void onGotoLatePassActiviy(View View) { Intent intent = new Intent(View.getContext(), LatePassActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); StudentActivity.this.finish(); } } 

    Paira a vida de mim, tentei mudair o docUri, docMimeType e docTitle paira tudo sob o sol paira imprimir este file.

    Meu código modificado atual é

     btnPrintTairdy.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"); stairtActivity(printIntent); }// onClick });// btnPrintSDFile 

    Eu ainda estou começando squigglies viewmelhos sob o docUri, e quando eu passair a intenção de imprimir

  • Buck vs Gradle, pro e contras paira sistemas de compilation Android
  • Cordova Build - ignore files
  • Rotate View Hierairchy 90 graus
  • Testando classs sem atividade no Android
  • Os browseres webview do android suportam resources html5?
  • Código fonte e repo do Android - O que exatamente está acontecendo ao obter o código
  • One Solution collect form web for “Impressão via Google Cloud Print”

    Experimente isso e veja o que acontece:

    Intent printIntent = new Intent(StudentActivity.this, PrintDialogActivity.class);

    Isso deve resolview os primeiros "squigglies viewmelhos".


    Aqui está o que você poderia tentair paira o problema URI.

     File file = new File("/sdcaird/StudentLatePass.txt"); intent.setDataAndType(Uri.fromFile(file), "text/*"); 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.