This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Building Blockchain Apps and have Michael Yuan on-line!
See this thread for details.
Win a copy of Building Blockchain Apps this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
Sheriffs:
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
Bartenders:
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

Images open in Android Studio but do not open when app is installed on phone

 
Ranch Hand
Posts: 65
2
IntelliJ IDE Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

My Problem:
I'm struggling to figure out why my app cannot open images (stored internal to the app in the Files directory created by the OS), but Android Studio and Emulator have no issue opening the images? When prompted to select an app (Gallery or Photo) on the phone, Gallery opens with an image of an explanation point, and selecting Photo results in a cursor hang on a blank screen.

The emulator build is Pixel version 9. The app is setup to the recommended minSdkVersion of 28, and compiled and targeted to 29. The phone is a Galaxy A10e which is also Android version 9.

What I have done:
I've worked with this code a lot since I'm 4-6 months new to Android development. I'm using the following Intentdriven code and have used a hard coded mime type (e.g. "image/jpeg"), a MimeTypeMap class in case that worked better, and also eliminated the mime type designation altogether. In all 3 cases, the app opened the images successfully in Android studio, but all failed when installed to the phone.

I'm not sure where to go from here. It is quite possible I'm missing a simple step or issue. If there is more that I can add to help me solve this issue I will be happy to provide it. I have posted this issue at StackOverflow (see link below), but I forgot about Java Ranch and Code Ranch and have had friendly, successful help here in the past with other Java projects. I tried to find the posting rules as to whether I was allowed to post since I did to StackOverflow, so I apologize if I broke any rules.




Posted question here also:
https://stackoverflow.com/questions/60767354/why-do-images-open-with-my-app-in-android-studio-but-when-installed-on-my-phone

 
Rancher
Posts: 453
7
Android Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess exception will be thrown when it hang on the blank screen.
Have you tried debug using your phone?
 
Scott Vallery
Ranch Hand
Posts: 65
2
IntelliJ IDE Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have not ever tried debugging with my phone so I took the time with your suggestions and tried. I started with "Run apps on a hardware device" on developer.android.com. When using Device Manager (Windows 10), I'm stuck on which driver to select, there are about 15-20. I used the wizard with searching sub folders and still received that the current driver was best. So I tried without since I kept getting the message that my current driver was the best. However, when I hook up the phone, it is an "unknown device" and click run the app fails to install and run. Any guidance would be helpful and then maybe I can find the real issue.

I've attached two images to clarify if needed.

https://developer.android.com/studio/run/device

usbdevice.JPG
[Thumbnail for usbdevice.JPG]
Samsung A10e device drivers up-to-date
usbdrivers.JPG
[Thumbnail for usbdrivers.JPG]
List of USB device drivers
 
Randy Tong
Rancher
Posts: 453
7
Android Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to go to phone setting, About Phone, tap build number 7 times.

https://www.howtogeek.com/129728/how-to-access-the-developer-options-menu-and-enable-usb-debugging-on-android-4.2/

Follow these steps:

https://developer.android.com/training/basics/firstapp/running-app
 
Scott Vallery
Ranch Hand
Posts: 65
2
IntelliJ IDE Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did figure out how to get the phone to run in debug, however, accidentally... I simply unplugged the phone and plugged it back in and then I needed to approve the permission for debugging.

The Run, Debug, Logcat and Build tabs have no errors, and neither does the Event log. The issues are still the same.
 
Randy Tong
Rancher
Posts: 453
7
Android Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How you stored the image ? Perhaps the path is not found in your device?
 
Scott Vallery
Ranch Hand
Posts: 65
2
IntelliJ IDE Eclipse IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I feel stupid but solved my problem. I had my createFiles() method off during some testing on building out the opening of files. When I pushed the app to the phone I forgot to turn it back on.

Thanks Randy for your patience and help.
 
crispy bacon. crispy tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!