Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6845159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:27:58+00:00 2026-05-27T00:27:58+00:00

My application attempts to find the orientation of the device by using: int orientation

  • 0

My application attempts to find the orientation of the device by using:

int orientation = getResources().getConfiguration.orientation;

This appears to work perfectly on my Samsung Galaxy S2 but when testing it on a HTC Desire HD and then trying to reference my integer in a Toast to check its finding the right orientation, it throws a Resources$NotFoundException.

Am I correct in thinking that this method of finding the phones orientation doesn’t always work, if so why does it not just throw a NullPointerException when I attempt to reference the integer?

My application captures a photo, I therefore need to find the phones orientation in order to set the dimensions for the SurfaceView and rotate the image as required. Is there any other way of finding the phones orientation?

Thanks in advance for any replies.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T00:27:59+00:00Added an answer on May 27, 2026 at 12:27 am

    When you call Toast.makeText(), note that there are two methods: makeText(Context context, int resId, int duration) and makeText(Context context, CharSequence text, int duration). When you use an integer, the first method is called, and Android tries to find a resource associated with the integer, which is not what you want.

    The simplest thing you can do instead is to convert your integer to string:

    Toast.makeText(context, Integer.toString(orientation), Toast.LENGTH_SHORT).show();
    

    This way Android won’t search for any resources and will show you the needed text.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing an application using DDD techniques. This is my first attempt at a
My Android application attempts to read the physical sectors of the SD card by
I have some code that attempts to test whether my application is running with
Total noob here. This is my first c# attempt, its a console application that
I have a grails application that attempts to use OpenID4Java to authenticate with our
I am working on a threaded application on Linux in C++ which attempts to
I have an application that is used in image processing, and I find myself
Windows application invokes business logic Business logic creates new e-mail using Exchange Web Services
I'm trying to convert an Application.cfc to script. The original had this: <cfcomponent displayname=Application
I am writing a csharp windows form application which attempts to check for the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.