gpt4 book ai didi

android - 当我调用 Activity 启动器方法时,应用程序随机崩溃

转载 作者:行者123 更新时间:2023-12-02 08:38:32 24 4
gpt4 key购买 nike

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

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)

最佳答案

尝试这些步骤

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

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

list 中的 Activity 声明中的内容相同

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

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

关于android - 当我调用 Activity 启动器方法时,应用程序随机崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17596460/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com