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. Not able to browse from the android emulator

I am using Windows XP machine with wired connection.
I am trying to browse from the android emulator installed on my
laptop.

It gives me this error.

Check to make sure your device has a signal and data connection
Reload this web page later
View a cached copy of the web page from Google.

Please help me to resolve this issue
Thanks in advance.

-- 

2. TabActivity setDefaultTab useless. TabHost bug?

I'am using a TabActivity where I add TabSpec's with Intent content
that starts child activities. I want to "remember" which tab is
active, so I store the "tag" in a SharedPreferences.

When restoring in onCreate, I use tabHost.setCurrentTab. This it work.
But looking at the log, the TabActivity also creates the first tabs
activity before the setCurrentTab call. I've also tried setDefaultTab,
it does nothing.

Example code:

public class MyActivity extends TabActivity {
  public void onCreate (Bundle state) {
    super.onCreate(state);
    setContentView(R.layout.main);
    TabHost tabHost = getTabHost();
    tabHost.addTab(tabHost.newTabSpec("tab1")
      .setIndicator("Tab1").setContent(new Intent(this,
Tab1Activity.class)));
    tabHost.addTab(tabHost.newTabSpec("tab2")
      .setIndicator("Tab2").setContent(new Intent(this,
Tab2Activity.class)));
    setDefaultTab("tab2"); // does nothing?
    tabHost.setCurrentTabByTag("tab2"); // too late, Tab1Activity
already created!
  }
}

Still Tab1Activity.onCreate is called, wasting memory.

Hmm. Looking at TabHost source it seems setCurrentTab is called in the
first addTab, always focusing on the first added TabSpec.  Bug?

-- 

3. Enterprise Market

4. Fwd: Contact Organization in Emulator different than Phone

5. new idea

6. web service access from net

7. Puzzel Alarm [In progress