我尝试了 text(*.txt) 文件打印它的工作良好,但是当我尝试 HWML 文件时它不起作用。这是我的代码。
主页.java
public class Home extends Activity{
private static final String FileName = "file.html";
Button button1;
final File file = new File(Environment.getExternalStorageDirectory().getAbsolutePath(), FileName);
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.home);
button1 = (Button) findViewById(R.id.button1);
button1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
Uri uri = Uri.fromFile( file );
Intent intent = new Intent ("org.androidprinting.intent.action.PRINT");
intent.setDataAndType( uri, "text/html" );
startActivity(intent);
//startActivityForResult(intent, 0);
}
});
}
}