在我的应用程序中,我使用启动屏幕活动将可驱动文件保存为 sd 卡或内置内存中的文件。效果很好,但是这个活动不显示内容视图。为什么这个活动保存文件但不显示内容视图?
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
for (int i = 0; i < DRAWABLES.length; i++) {
saveDrawables(
BitmapFactory.decodeResource(getResources(), DRAWABLES[i]),
String.valueOf(i + 2));
}
startActivity(new Intent(SplashActivity.this, MotivateActivity.class));
finish();
}
public void saveDrawables(Bitmap drawable, String drawableName) {
try {
String filename = drawableName + ".jpg";
Log.i("Local filename:", "" + filename);
File dir = new File(Environment.getExternalStorageDirectory()
+ "/MotivateMe/");
File file = new File(dir, filename);
if (!dir.exists()) {
dir.mkdirs();
}
if (file.createNewFile()) {
file.createNewFile();
}
FileOutputStream fileOutput = new FileOutputStream(file);
drawable.compress(Bitmap.CompressFormat.JPEG, 100, fileOutput);
fileOutput.close();
} catch (Exception exception) {
}
}
}