0

当按下调用跟随侦听器的两个按钮之一时

OnClickListener mSportiveListener = new OnClickListener() {
    public void onClick(View v) {
        String title = getResources().getString(
                R.string.function_sport_i);
        String category="SPORT";
        startFunctionSelector(title, category);
    }
};

OnClickListener mClassicListener = new OnClickListener() {
    public void onClick(View v) {
        String title = getResources().getString(
                R.string.function_classic_i);
        String category="CLASSIC";
        startFunctionSelector(title, category);
    }
};

应用程序经常崩溃,其中包含有关恰好在线发生的错误的任何详细信息

startActivity(selector);

方法的

public void startFunctionSelector(String title, String functionCategory) {
    Intent selector = new Intent(Home.this, FunctionSelector.class);
    selector.putExtra("Title", title);
    selector.putExtra("FunctionCategory", functionCategory);
    try {
        startActivity(selector);
    } catch (RuntimeException e) {
        e.printStackTrace();
    }

}

该错误与我输入的任何内容无关FunctionSelector.class,因此行为完全相同(我也尝试过使用 Hello World)

不幸的是,由于一些奇怪的原因,Eclipse 没有给我任何关于错误的细节,只有一个通用的 SourceNotFound

// Compiled from Handler.java (version 1.5 : 49.0, super bit)
public class android.os.Handler {

  // Method descriptor #11 ()V
  // Stack: 3, Locals: 1
  public Handler();
     0  aload_0 [this]
     1  invokespecial java.lang.Object() [1]
     4  new java.lang.RuntimeException [2]
     7  dup
     8  ldc <String "Stub!"> [3]
    10  invokespecial java.lang.RuntimeException(java.lang.String) [4]
    13  athrow
      Line numbers:
        [pc: 0, line: 8]
      Local variable table:
        [pc: 0, pc: 14] local: this index: 0 type: android.os.Handler

但没有具体说明这个问题。

更多细节

FunctionSelector 的 onCreate,但正如我所说的,如果我在这个 Activity 中只留下一个 helloWorld,也会崩溃

 public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
                    .permitAll().build();
            StrictMode.setThreadPolicy(policy);
            setContentView(R.layout.selector_gui);

            selectorTitle = getIntent().getStringExtra("Title");
            functionCategory = getIntent().getStringExtra("FunctionCategory");

            buttonBack = (ImageButton) findViewById(R.id.btBack);
            buttonBack.setOnClickListener(mBackListener);

            txtTitle = (TextView) findViewById(R.id.txtTitle);
            txtTitle.setText(selectorTitle);

            list = (ListView) findViewById(R.id.listaFunzioni);

        }

如果我尝试使用模拟器并进入 AllMessage(每个应用程序未过滤),我可以看到

07-11 14:25:51.139: E/ActivityThread(1550): Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@b2f46948 that was originally bound here
07-11 14:25:51.139: E/ActivityThread(1550): android.app.ServiceConnectionLeaked: Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@b2f46948 that was originally bound here
07-11 14:25:51.139: E/ActivityThread(1550):     at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:969)
07-11 14:25:51.139: E/ActivityThread(1550):     at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:863)
07-11 14:25:51.139: E/ActivityThread(1550):     at android.app.ContextImpl.bindService(ContextImpl.java:1418)
07-11 14:25:51.139: E/ActivityThread(1550):     at android.app.ContextImpl.bindService(ContextImpl.java:1407)
07-11 14:25:51.139: E/ActivityThread(1550):     at android.content.ContextWrapper.bindService(ContextWrapper.java:473)
07-11 14:25:51.139: E/ActivityThread(1550):     at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:157)
07-11 14:25:51.139: E/ActivityThread(1550):     at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:145)
07-11 14:25:51.139: E/ActivityThread(1550):     at com.android.emailcommon.service.AccountServiceProxy.getDeviceId(AccountServiceProxy.java:116)
07-11 14:25:51.139: E/ActivityThread(1550):     at com.android.exchange.ExchangeService.getDeviceId(ExchangeService.java:1249)
07-11 14:25:51.139: E/ActivityThread(1550):     at com.android.exchange.ExchangeService$7.run(ExchangeService.java:1856)
07-11 14:25:51.139: E/ActivityThread(1550):     at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:551)
07-11 14:25:51.139: E/ActivityThread(1550):     at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:549)
07-11 14:25:51.139: E/ActivityThread(1550):     at android.os.AsyncTask$2.call(AsyncTask.java:287)
07-11 14:25:51.139: E/ActivityThread(1550):     at java.util.concurrent.FutureTask.run(FutureTask.java:234)
07-11 14:25:51.139: E/ActivityThread(1550):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
07-11 14:25:51.139: E/ActivityThread(1550):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
07-11 14:25:51.139: E/ActivityThread(1550):     at java.lang.Thread.run(Thread.java:856)
07-11 14:25:51.139: E/StrictMode(1550): null
07-11 14:25:51.139: E/StrictMode(1550): android.app.ServiceConnectionLeaked: Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@b2f46948 that was originally bound here
07-11 14:25:51.139: E/StrictMode(1550):     at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:969)
07-11 14:25:51.139: E/StrictMode(1550):     at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:863)
07-11 14:25:51.139: E/StrictMode(1550):     at android.app.ContextImpl.bindService(ContextImpl.java:1418)
07-11 14:25:51.139: E/StrictMode(1550):     at android.app.ContextImpl.bindService(ContextImpl.java:1407)
07-11 14:25:51.139: E/StrictMode(1550):     at android.content.ContextWrapper.bindService(ContextWrapper.java:473)
07-11 14:25:51.139: E/StrictMode(1550):     at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:157)
07-11 14:25:51.139: E/StrictMode(1550):     at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:145)
07-11 14:25:51.139: E/StrictMode(1550):     at com.android.emailcommon.service.AccountServiceProxy.getDeviceId(AccountServiceProxy.java:116)
07-11 14:25:51.139: E/StrictMode(1550):     at com.android.exchange.ExchangeService.getDeviceId(ExchangeService.java:1249)
07-11 14:25:51.139: E/StrictMode(1550):     at com.android.exchange.ExchangeService$7.run(ExchangeService.java:1856)
07-11 14:25:51.139: E/StrictMode(1550):     at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:551)
07-11 14:25:51.139: E/StrictMode(1550):     at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:549)
07-11 14:25:51.139: E/StrictMode(1550):     at android.os.AsyncTask$2.call(AsyncTask.java:287)
07-11 14:25:51.139: E/StrictMode(1550):     at java.util.concurrent.FutureTask.run(FutureTask.java:234)
07-11 14:25:51.139: E/StrictMode(1550):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
07-11 14:25:51.139: E/StrictMode(1550):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
07-11 14:25:51.139: E/StrictMode(1550):     at java.lang.Thread.run(Thread.java:856)
07-11 14:25:51.139: W/ActivityManager(1201): Unbind failed: could not find connection for android.os.BinderProxy@b3149200
07-11 14:25:51.139: E/ActivityThread(1550): Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@b2f7f7c0 that was originally bound here
07-11 14:25:51.139: E/ActivityThread(1550): android.app.ServiceConnectionLeaked: Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@b2f7f7c0 that was originally bound here
07-11 14:25:51.139: E/ActivityThread(1550):     at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:969)
07-11 14:25:51.139: E/ActivityThread(1550):     at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:863)
07-11 14:25:51.139: E/ActivityThread(1550):     at android.app.ContextImpl.bindService(ContextImpl.java:1418)
07-11 14:25:51.139: E/ActivityThread(1550):     at android.app.ContextImpl.bindService(ContextImpl.java:1407)
07-11 14:25:51.139: E/ActivityThread(1550):     at android.content.ContextWrapper.bindService(ContextWrapper.java:473)
07-11 14:25:51.139: E/ActivityThread(1550):     at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:157)
07-11 14:25:51.139: E/ActivityThread(1550):     at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:145)
07-11 14:25:51.139: E/ActivityThread(1550):     at com.android.emailcommon.service.ServiceProxy.test(ServiceProxy.java:191)
07-11 14:25:51.139: E/ActivityThread(1550):     at com.android.exchange.ExchangeService$7.run(ExchangeService.java:1850)
07-11 14:25:51.139: E/ActivityThread(1550):     at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:551)
07-11 14:25:51.139: E/ActivityThread(1550):     at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:549)
07-11 14:25:51.139: E/ActivityThread(1550):     at android.os.AsyncTask$2.call(AsyncTask.java:287)
07-11 14:25:51.139: E/ActivityThread(1550):     at java.util.concurrent.FutureTask.run(FutureTask.java:234)
07-11 14:25:51.139: E/ActivityThread(1550):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
07-11 14:25:51.139: E/ActivityThread(1550):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
07-11 14:25:51.139: E/ActivityThread(1550):     at java.lang.Thread.run(Thread.java:856)
07-11 14:25:51.139: E/StrictMode(1550): null
07-11 14:25:51.139: E/StrictMode(1550): android.app.ServiceConnectionLeaked: Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@b2f7f7c0 that was originally bound here
07-11 14:25:51.139: E/StrictMode(1550):     at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:969)
07-11 14:25:51.139: E/StrictMode(1550):     at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:863)
07-11 14:25:51.139: E/StrictMode(1550):     at android.app.ContextImpl.bindService(ContextImpl.java:1418)
07-11 14:25:51.139: E/StrictMode(1550):     at android.app.ContextImpl.bindService(ContextImpl.java:1407)
07-11 14:25:51.139: E/StrictMode(1550):     at android.content.ContextWrapper.bindService(ContextWrapper.java:473)
07-11 14:25:51.139: E/StrictMode(1550):     at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:157)
07-11 14:25:51.139: E/StrictMode(1550):     at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:145)
07-11 14:25:51.139: E/StrictMode(1550):     at com.android.emailcommon.service.ServiceProxy.test(ServiceProxy.java:191)
07-11 14:25:51.139: E/StrictMode(1550):     at com.android.exchange.ExchangeService$7.run(ExchangeService.java:1850)
07-11 14:25:51.139: E/StrictMode(1550):     at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:551)
07-11 14:25:51.139: E/StrictMode(1550):     at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:549)
07-11 14:25:51.139: E/StrictMode(1550):     at android.os.AsyncTask$2.call(AsyncTask.java:287)
07-11 14:25:51.139: E/StrictMode(1550):     at java.util.concurrent.FutureTask.run(FutureTask.java:234)
07-11 14:25:51.139: E/StrictMode(1550):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
07-11 14:25:51.139: E/StrictMode(1550):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
07-11 14:25:51.139: E/StrictMode(1550):     at java.lang.Thread.run(Thread.java:856)
4

1 回答 1

1

试试这些步骤

1)尝试在初始化 Intent 时包含活动的完整路径,例如

Intent selector = new Intent(Home.this, com.yourpackagename.YourActivity.class); 

清单中的活动声明中的相同内容

2) 验证所有资源是否正确链接,并且清单和 gui 的 xml 文件中没有错误

3)假设你已经在manifest中声明了Activity,并且on create中的资源都被正确初始化了。Eclipse 缓存中可能出现问题,删除工作区中的 .metadata 文件夹并尝试重新导入项目。

于 2013-07-11T15:20:36.913 回答