- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- Button button = (Button) this.findViewById(R.id.button);
- button.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- Intent intent = new Intent(Intent.ACTION_VIEW);
- intent.addCategory(Intent.CATEGORY_DEFAULT);
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- style="WHITE-SPACE: pre"> </SPAN>Uri uri = Uri.fromFile(new File("/data/data/com.example/files/test.txt"));
- intent.setDataAndType(uri, "text/plain");
- startActivity(intent);
- }
- });
Android打开TXT文件
最新推荐文章于 2023-03-26 22:58:58 发布