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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T20:25:22+00:00 2026-06-08T20:25:22+00:00

Here is the code Variable declared public String gpu2dcurent = 1234567; Asynctask, after finished

  • 0

Here is the code

Variable declared

 public String gpu2dcurent = "1234567";

Asynctask, after finished it should update variable gpu2dcurent, but it doesnt

 private class readgpu2d extends AsyncTask<String, Void, String> {


    protected String doInBackground(String... args) {
         Log.i("MyApp", "Background thread starting");

         String aBuffer = "";

         try {

            File myFile = new File("/sys/devices/platform/kgsl-2d0.0/kgsl/kgsl-2d0/gpuclk");
            FileInputStream fIn = new FileInputStream(myFile);
            BufferedReader myReader = new BufferedReader(
                    new InputStreamReader(fIn));
            String aDataRow = "";
            //String aBuffer = "";
            while ((aDataRow = myReader.readLine()) != null) {
                aBuffer += aDataRow + "\n";
            }

            ;
            myReader.close();

        } catch (Exception e) {
            Toast.makeText(getBaseContext(), e.getMessage(),
                    Toast.LENGTH_SHORT).show();

        }

         return aBuffer.trim();
     }

     protected void onPostExecute(String result) {
         // Pass the result data back to the main activity
        gpu2dcurent = result;
         //Toast.makeText(getBaseContext(), result,
                //Toast.LENGTH_SHORT).show();
         gpu.this.data = result;

         if (gpu.this.pd != null) {
             //gpu.this.pd.dismiss();
         }
     }

    }

Test to see if a variable has a new value. It doesn’t, it displays 1234567

 TextView tx = (TextView)findViewById(R.id.textView3);
tx.setText(gpu2dcurent);

Am i missing something? When i update textView from inside onPostExecute method it works fine but when Asynctask finishes variable value resets to default

 public class gpu extends Activity{

public String gpu2dcurent = "1234567";
  • 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-08T20:25:24+00:00Added an answer on June 8, 2026 at 8:25 pm

    I have a doubt you are trying to set text of TextView before completion of your Asynctask.

    Yes, either make it, static public String gpu2dcurent = "1234567";

    Or, set Text of TextView in onPostExecute()

    protected void onPostExecute(String result) {
             // Pass the result data back to the main activity
            gpu2dcurent = result;
             //Toast.makeText(getBaseContext(), result,
                    //Toast.LENGTH_SHORT).show();
             gpu.this.data = result;  
             if (gpu.this.pd != null) {
                 //gpu.this.pd.dismiss();
             }
          tx.setText(gpu2dcurent);
         }
        }
    

    Update:

    After update your code in question,

    change this line,

    new readgpu2d().execute("blablabla");
    

    to

    new readgpu2d().execute("blablabla").get();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's my code: Public Function selectReturnsByUserId( limit As Integer, userid As String ) As
Here's the code: //check if the starting row variable was passed in the URL
Here is my code... basically it finds any page-NUMBER- within a variable and then
I have this code right here, where the $friends variable is an array with
I have a code segment: public class MyClass { private string _myProperty; public string
I've declared a String variable test with hi. every time I click on Button1,
Here is my code: $(document).ready(function(){ //These variables are for loading more posts var create_ptr
The following code utilizes CreateProcess to run commands with environmental variables. Here, it tries
I am trying to insert php variables into javascript. Here is the broken code:
The script is on jsfiddle here : CODE What it does at the moment

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.