Can't figure out this compile error

by Tobiah » Sat, 15 Jan 2011 01:58:38 GMT


Sponsored Links
 Trying to launch an IntentService:


package com.rcsreg.exposmart;
import android.app.IntentService;
import android.util.Log;
import android.content.Intent;

public class Sync extends IntentService{

        Integer counter = 0;

        public void Sync(){
                super("Sync");
        }

        @Override
        protected void onHandleIntent(Intent intent){
                while(1 == 1){
                        Log.e("INTENT!!!!", String.format("COUNT IS %d", 
counter++));
                        try{
                                Thread.sleep(3000);
                        } catch (Exception e){
                        }
                }
        }
}


Compiler says:

[javac] Compiling 2 source files to /home/toby/android/exposmart/bin/classes
    [javac] /home/toby/android/exposmart/src/com/rcsreg/exposmart/Sync.java:6: 
cannot find symbol
    [javac] symbol  : constructor IntentService()
    [javac] location: class android.app.IntentService
    [javac] public class Sync extends IntentService{
    [javac]        ^
    [javac] /home/toby/android/exposmart/src/com/rcsreg/exposmart/Sync.java:11: 
call to super must be first statement in constructor
    [javac]             super("Sync");
    [javac]                  ^
    [javac] 2 errors

Thanks,


Tobiah

--



Re: Can't figure out this compile error

by Hari Edo » Sat, 15 Jan 2011 03:28:17 GMT


 > public class Sync extends IntentService
--->   Integer counter;
--->               counter = 0;
...

-- 


Sponsored Links


Re: Re: Can't figure out this compile error

by Tobiah » Sat, 15 Jan 2011 03:50:31 GMT


 

public class Sync extends IntentService {
---> Integer counter;
public void Sync() { super("Sync");
---> counter = 0;
}
...
}
It turned out that I needed to axe the 'void' in the constructor. Thanks --



Other Threads

1. OutOfMemory Error (Animation)

I am making a simple rpg game that uses animation to move characters
around. In one scene I am working on there is 4 things that happen:

1)The character walks on screen
2)A gun shot is heard when the user clicks on screen the first time
and a bullet hole appears in a window.
3) The user is given two options, shoot back or get in car. The shoot
back button does what you think it does and the character pulls out a
gun and another gunshot is heard.
4) If get in car is pressed the character walks to the car, gets in
and drives away.

The problem is the program force closes if you click the shoot back
button and then click get in car. The problem that I see from
debugging is "OutOfMemory" error. The game runs perfectly on the Nexus
One but any other phone with an inferior processor force closes. Could
anyone point out a way to save memory on this? Do I have to purposely
finish() the previous activities or is there a problem with the code
below (note that the threads it calls just are for timing the gunshot
sounds to line up with the animation).

public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.scene1);

        mSoundManager = new SoundManager();
        mSoundManager.initSounds(getBaseContext());
        mSoundManager.addSound(3, R.raw.gun_silencer);
        mSoundManager.addSound(5, R.raw.glass_break);

        character_img = (ImageView) findViewById(R.id.character_img);
        character_img.setBackgroundResource(R.anim.scene1_anim);
        scene1_anim = (AnimationDrawable) character_img.getBackground
();
        scene1_anim.setOneShot(true);

        Scene1Thread = new Scene1Thread();
        Scene1Thread2 = new Scene1Thread2();

        scene1_bg_img = (RelativeLayout) findViewById
(R.id.scene1_bg_img);
        btn_shoot_back = (Button) findViewById(R.id.btn_shoot_back);
        btn_getin_car = (Button) findViewById(R.id.btn_getin_car);

        btn_shoot_back.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                btn_shoot_back.setVisibility(Button.INVISIBLE);
                btn_shoot_back.setClickable(false);
                character_img.setBackgroundResource
(R.anim.scene1_shoot_back);
                scene1_shoot_back = (AnimationDrawable)
character_img.getBackground();
                scene1_shoot_back.setOneShot(true);
                scene1_shoot_back.start();
                Scene1Thread2.start();

            }
        });
        btn_getin_car.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                btn_getin_car.setVisibility(Button.INVISIBLE);
                btn_getin_car.setClickable(false);
                if (btn_shoot_back.getVisibility() == Button.VISIBLE) {
                        btn_shoot_back.setVisibility(Button.INVISIBLE);
                        btn_shoot_back.setClickable(false);
                }
                character_img.setBackgroundResource
(R.anim.scene1_getin_car);
                scene1_getin_car = (AnimationDrawable)
character_img.getBackground();
                scene1_getin_car.setOneShot(true);
                scene1_getin_car.start();

            }
        });

        shot_vibrate = ({*filter*}) getSystemService
(Context.{*filter*}_SERVICE);


        character_img.post(new Starter());

        btn_gun_shot = (ImageButton) findViewById(R.id.btn_gun_shot);
        btn_gun_shot.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                scene1_bg_img.setBackgroundResource
(R.drawable.scene1_bg_shot);
                Scene1Thread.start();
                shot_vibrate.vibrate(250);
                btn_gun_shot.setClickable(false);
                btn_shoot_back.setVisibility(Button.VISIBLE);
                btn_getin_car.setVisibility(Button.VISIBLE);
            }

        });

        }
        class Starter implements Runnable {

        public void run() {
                scene1_anim.start();

        }

}


Please and Thank you.

2. Getting "some" of the Android source

I would like to get the source for NumberPicker dialog.  Looking at the 
page on getting the source it is hard to sort out what I need and what I 
don't need as far as tools go.  I have no intention of building the full 
source but just the NumberPicker source file to drop in to my app (the 
layout XMLs in the SDK). It's all probably  "old hat" to people who have 
worked in corporate develop environment but I haven't for years and this 
stuff wasn't really around back then.  So if you just want to grab a 
source file what do your really need?

- Brian



--

3. who can give a summary about the strong reference and weak reference in Android

4. Unable to start download in Browser

5. java.lang.IllgealArgumentException:OnCreateDialog did not create a dialog for id ..

6. code stepping icons disabled

7. Keys don't work with SurfaceView