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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:55:02+00:00 2026-06-10T00:55:02+00:00

I was checking how it looks to debug an application on an actual device.

  • 0

I was checking how it looks to debug an application on an actual device. Following code just changes the text of a button according to the number of times it is pressed repeatedly.

It was increasing perfectly, but as I tilted the device and it switched to landscape, the button changed its text to to initial state. I pressed again and tilted again, the value again got reset.

What is going on in background? and how to stop it?

b.setOnClickListener( new OnClickListener() {
    int i = 1;

    @Override
    public void onClick(View v) {
        // TODO Auto-generated method stub
        // Toast.makeText(MainActivity.this, "Pressed ", Toast.LENGTH_SHORT).show();
        b.setText("press "+ i);
        i++;
    }
});
  • 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-10T00:55:03+00:00Added an answer on June 10, 2026 at 12:55 am

    When you tilt the device your activity is destroyed and oncreate is called again .
    You have to retain the value you want to get back when its is restarted.
    There are several ways to do it .
    In shortcut you can just add a flag in Activity in manifest file which is android:configchanges = “orientation”.

    <activity
                android:name=".Splash"
                android:configChanges="orientation"
                android:screenOrientation="portrait"
                android:theme="@android:style/Theme.NoTitleBar" >
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>
    

    Aur save your values in onPause or onBundleSaveinstance lifecycle callback methods.

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

Sidebar

Related Questions

I've been checking out WCF Data Services today and it looks great - but
This is what it looks like: artifact org.springframework:spring-core: checking for updates from glassfish-repository WARNING]
Just checking my JS and I have an error, but I cannot see where.
when checking the source code of a site on firefox I got this on
I'm using the following code to accept bad server certificates: ServicePointManager.ServerCertificateValidationCallback = delegate(object s,
My website has an opt-in member directory. Currently, the error checking function simply looks
Would someone mind checking my site in Firebug? It looks like the jquery hide/show
Jquery code looks like: $('#gal').rating('gl.php?gal_no=<?=$gal_no;?>&id=<?=$id;?>', {maxvalue:10,increment:.5, curvalue: <?=$cur;?>}); PHP code: $br=mysql_query(SELECT count(gal) as total
I just been given a new assignment which looks like its going to be
Checking for cookies with code below if (!isset($_COOKIE['auth'])) { header('Location:' . wsurl); } My

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.