3
是否可以打開一個圖片,該圖片存儲在resview/drawable文件夾中與Android構建在圖像查看器?我不明白它的工作。我試過follwoing方式打開圖片存儲在res/drawable與buildin Android圖像查看器
Button ButtonPhase2 = (Button) findViewById(R.id.button1);
ButtonPhase2.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent myIntent = new Intent(android.content.Intent.ACTION_VIEW);
myIntent.setData(Uri.parse("android.resource://de.test.app/" + R.drawable.testbild));
myIntent.setType("image/png");
startActivityForResult(myIntent, 1);
}
});
但我得到的錯誤:
Unable to start Activity ComponentInfo{com.android.gallery/com.android.camera.ViewImage}: java.lang.nullPointerException
我認爲這是錯誤的道路?
你可能請更準確地定義這一點,因爲當我這樣做時,當我點擊圖標時,不會在構建Android圖像查看器中打開某些內容。 – Samson
我已更新我的代碼 –