English 中文(简体)
Android 启动活动时的例外:java.lang.IllegalStateException: System services not available to Activities before on Create ()
原标题:Android Exception when starting activity: java.lang.IllegalStateException: System services not available to Activities before onCreate()
  • 时间:2012-01-14 15:51:23
  •  标签:
  • android

在我和roid申请开始时,我有这样的例外:

01-14 16:40:41.725: E/AndroidRuntime(11341): FATAL EXCEPTION: main
01-14 16:40:41.725: E/AndroidRuntime(11341): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{es.landesoft/es.landesoft.LandeSoftActivity}: java.lang.IllegalStateException: System services not available to Activities before onCreate()
01-14 16:40:41.725: E/AndroidRuntime(11341):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1573)
01-14 16:40:41.725: E/AndroidRuntime(11341):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
01-14 16:40:41.725: E/AndroidRuntime(11341):    at android.app.ActivityThread.access$1500(ActivityThread.java:117)
01-14 16:40:41.725: E/AndroidRuntime(11341):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
01-14 16:40:41.725: E/AndroidRuntime(11341):    at android.os.Handler.dispatchMessage(Handler.java:99)
01-14 16:40:41.725: E/AndroidRuntime(11341):    at android.os.Looper.loop(Looper.java:130)
01-14 16:40:41.725: E/AndroidRuntime(11341):    at android.app.ActivityThread.main(ActivityThread.java:3691)
01-14 16:40:41.725: E/AndroidRuntime(11341):    at java.lang.reflect.Method.invokeNative(Native Method)
01-14 16:40:41.725: E/AndroidRuntime(11341):    at java.lang.reflect.Method.invoke(Method.java:507)
01-14 16:40:41.725: E/AndroidRuntime(11341):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907)

This is the beginning of the Class and the Oncreate Method. I know you can not use System Services before onCreate() and I think I am not doing it because I only fire the code with the layout buttons.

public class LandeSoftActivity extends Activity {
    /** Called when the activity is first created. */

    TextView lblEnvio;
    EditText txtDestinatarios;
    EditText txtAsunto;
    EditText txtMensaje;
    private String ResStr;
    private String ResEnvio;



    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        Button botonEnviar = (Button) findViewById(es.landesoft.R.id.btnSend);

        botonEnviar.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {

                Thread Hilo = new Thread(new Runnable() {

                    public void run() {

                        ResEnvio= EnviarEMailWS();
                        handler.sendEmptyMessage(0);
                    }
                });
                Hilo.start();
                lblEnvio.setText(ResEnvio);

            }
        });

        Button BtnSysInfo = (Button) findViewById(es.landesoft.R.id.btnSysInfo);
        BtnSysInfo.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {

                Thread Hilo = new Thread(new Runnable() {

                    public void run() {
                    ResStr =RequestWSInfo();
                    handler.sendEmptyMessage(0);                        
                    }
                });

                Hilo.start();
                ShowToastMsg(ResStr, 12000);

            }
        });

        lblEnvio = (TextView) findViewById(es.landesoft.R.id.textView1);
        txtDestinatarios = (EditText) findViewById(es.landesoft.R.id.editText1);
        txtAsunto= (EditText) findViewById(es.landesoft.R.id.txtAsunto);
        txtMensaje= (EditText) findViewById(es.landesoft.R.id.txtMensaje);

我希望你能够帮助我。 我猜测这个问题是进步,但我不是打开窗户。

Thanks in advance!. }

最佳回答

奥克·我制造了问题,感到担忧。 我复制并贴出一些法典,并用“进步”宣布“进步”。 • 显示使用系统服务而不允许作为全球变量的方法。 感谢Jan-Henk。

问题回答

暂无回答




相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签