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 8117519
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T04:11:51+00:00 2026-06-06T04:11:51+00:00

Here is an interesting one… I have an application I am writing for devices

  • 0

Here is an interesting one…

I have an application I am writing for devices running android 2.3.3 and above.

It has a main activity which calls the camera via an Intent.

If the user clicks a button to launch the camera; then takes a picture; then clicks “Done” to return to the main activity – the application works fine and displays the new picture in an imageview on the main activity.

however, if the user uses the main activity in portrait orientation; then clicks the button to open the camera intent and changes the orientation to landscape; then click done to return to the main activity – the application crashes

but then…however, if the user uses the main activity in portrait orientation; then clicks the button to open the camera intent and changes the orientation to landscape; then changes the orientation back to portrait (in the camera) before clicking done to return to the main activity – then the application continues to run normally.

Stuff I have tried:
I have changed the manifest file to force the application (main activity) to be oriented in portrait (I have also removed this)
I have added this line to the main activity in an attempt to handle the re-drawing of the activity on it return from the camera intent:

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

In the debug window I get errors describing nullpointer exceptions – I think this is because the views are no longer there after an orientation change for the image to be passed into unless the orientation is the same as when it was left.

I’m a bit stuck so would appreciate some advice.

  • 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-06-06T04:11:53+00:00Added an answer on June 6, 2026 at 4:11 am

    When your screen orientation changes, your Activity is destroyed and recreated in the new orientation. So any variables that gained a reference during the life of the Activity will no longer refer to anything, and if you then try to access objects they refer to without re-assigning them values, you’ll get a NullPointerException.

    The method onSaveInstanceState() is used to save temporary data between configuration changes. This creates a Bundle which is passed to onCreate() when the Activity starts up again.

    Without any code, I don’t know if that’s your problem, but it’s worth a look.

    See http://developer.android.com/reference/android/app/Activity.html#ConfigurationChanges for more information (and more accurate information than I’ve provided, no doubt).

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

Sidebar

Related Questions

I have a jar file of my application which has more than one class.
Interesting one here. I have an ASP.NET 1.1 project that contains a web service
Here's an interesting one - in VS2005 / VS2008 running against .NET 2.0 /
Interesting one, this. I have the following JS code, which I'm displaying in a
Here is one very interesting problem. I am using SQL Server 2008. I have
Here's an interesting one... hope I can explain it well... I have a collection
Here's an interesting one. Anyone have a good RegEx for converting all (first) ^
So here's an interesting conundrum. I have a page, default.aspx. It has a LINK
Hey guys, I have an interesting one for you here! I have one object,
Hi all i have developed a calendar from here http://keith-wood.name/datepick.html in my application which

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.