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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:14:14+00:00 2026-06-14T04:14:14+00:00

I have a method in my class named InvokeService() and inside It I am

  • 0

I have a method in my class named InvokeService() and inside It I am storing an Int value from a remoteservice.

like this

int hvactemp=remoteService.getHvacTemp();

and I am storing this value in to a textview.

drivertmpcount.setText(Integer.toString(hvactemp));

Now I want to incresae and decrease this value on button click.

I have two buttons declared in my code and the problem is

If I click right button the value is Increasing

suppose the value is 30 its increasing like 30,31,32,33,34,35 and so on..

But the problem is when I click left button its not decresing from the value Which I have present, as I said after incresing the value is 35 so now If I press left button it should go like this 34,32,31,32

but its decreasing from 30,29,28,27 instead of 35,34,32,31

How to solve this?

Here is my code.

 private void invokeService() {

    if (conn == null) {
        // Toast.makeText(CarHome.this, "Cannot invoke - service not bound",
        // Toast.LENGTH_SHORT).show();
    } else {
        try {
            System.out.println(remoteService);

            int rpm = remoteService.getEnginRPM();
            int temp = remoteService.getTemperature();
            // int battery = remoteService.getBatteryLevel();
            int speed = remoteService.getSpeed();
            final int hvactemp = remoteService.getHvacTemp();
            System.out.println("Raghav hvac" + hvactemp);

            System.out.println("jaydeep speed" + speed);
            // rpm_text.setText(rpm);


        drivertmpcount.setText(Integer.toString(hvactemp));


            driverbtnright.setOnClickListener(new View.OnClickListener() {

                int hvactemp=remoteService.getHvacTemp();



                public void onClick(View v) {
                    // TODO Auto-generated method stub

                    hvactemp++;
                    drivertmpcount.setText(Integer.toString(hvactemp));
                     System.out.println("Raghav hvac" + hvactemp);


                }
            });

            driverbtnleft.setOnClickListener(new View.OnClickListener() {
                int hvactemp=remoteService.getHvacTemp();
                public void onClick(View v) {
                    // TODO Auto-generated method stub


                    //  drivertmpcount.setText(Integer.toString(hvactemp));
                    hvactemp --;
                    drivertmpcount.setText(Integer.toString(hvactemp));
                     System.out.println("Raghav decrement hvac" + hvactemp);

                }
            });  
  • 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-14T04:14:15+00:00Added an answer on June 14, 2026 at 4:14 am

    You are wrong with code flow.

    Remove this int hvactemp=remoteService.getHvacTemp(); from two click Listener and declare hvactemp as a class variable.

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

Sidebar

Related Questions

Let's say I have a class method named ->saveAll() . This class tracks the
I have a class named Entry declared like this: class Entry{ string Id {get;set;}
The Java class library has a class named DateTime. DateTime has this method: int
I have a form that looks something like this <form action=# class=ajax_form method=post id=comment_form
I Create a class named DataClass there i have this method +(NSMutableArray*) returnList :(NSString
I have a custom class named CatalogItem which I receive in a method, as
I have two class files hudlayer.m and actionlayer.m I have a method named jump
I have 2 classes, Parent and Child, and Parent has a class method named
I have a class named ActivityLog . This class holds a list of ActivityRecords
I have a class named Defense with custom init method as below: // initialize

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.