0

I am building an application and in one of my activities, I am displaying some information from a database and one image, this image is scaled down and when the user press the image, I am launching the built-in gallery to view it in a larger size.

My problem here is the following when I am done looking at the image in the gallery, I want the user when he press the back button to go back to my app and exactly to the activity that launches the gallery, my application show me a crash message and direct me to the main activity of my app

here is the code that launches the built-in gallery

imageView.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            Intent intent = new Intent();
            intent.setAction(Intent.ACTION_VIEW);
            intent.setDataAndType(Uri.fromFile(new   
                         File(image_file.getAbsolutePath())),"image/*");
            startActivityForResult(intent, 1);
        }
    });

I tried using startActivity(intent); but that still not working.

I also tried to override onPuase() and onResume() but after I did, the entire activity that hold the imageView does not launch and the app crashes.

when I looked up something similar to this problem, people say that I may have bad manifest but I am doing nothing for that Activity in my manifest.

How can I fix the problem so the user can see the image in the built-in or any other gallery app then presses the back button to go back to my app?

thanks

4

1 回答 1

0

我不确定,但请在您的点击监听器中尝试以下代码

imageView.setOnClickListener(new View.OnClickListener() {
 Intent intent = new Intent();
 intent.setType("image/*");
 intent.setAction(Intent.ACTION_GET_CONTENT);
 startActivityForResult(Intent.createChooser(intent, "Complete action using"), PICK_FROM_FILE);
}
 });
于 2012-07-31T17:32:48.473 回答