1

私はAndroidアプリを初めて使用し、友人が始めたプロジェクトに取り組んでいます。以下のコードは、テキストが周囲にある小さな画像を含むビューをロードするクラスからのものです。

サムネイルをクリックしたときに、画像を(標準のAndroid画像ビューアで)フルスクリーンで表示したい。私はいくつかの異なる解決策を試しましたが、どれもうまくいきませんでした。

この例では、次の例外がスローされます。

E/AndroidRuntime(13768): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=android.resource://com.app.mid/2130837533 typ=image/png }
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.view_n1);

    ImageView img = (ImageView) findViewById(imageResource);

    img.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {

            Intent intent = new Intent();
            intent.setAction(android.content.Intent.ACTION_VIEW);
            intent.setDataAndType(Uri.parse("android.resource://com.app.mid/" + R.drawable.p_page_11_image_0001), "image/png");
            startActivity(intent);              
        }
    });        
}

画像はドローアブルフォルダ(.. \ res \ drawable-xhdpi)内にあります。Eclipse ADTを使用していて、GalaxyNexusで実行するように構成しました。

繰り返しますが、私は運が悪かったいくつかの解決策を試しました。何かご意見は?ありがとう

4

1 に答える 1

1

android.content.Intent.ACTION_VIEW の代わりに Intent.ACTION_VIEW を使用してみてください

Intent i = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(yourUri, "image/png");
startActivity(intent);
于 2013-03-07T23:38:43.463 に答える