gpt4 book ai didi

java - startactivity() 关闭应用程序

转载 作者:行者123 更新时间:2023-12-02 06:54:03 25 4
gpt4 key购买 nike

我有以下 Activity ,当调用 startactivity() 时,应用程序被强制关闭,我已经搜索了几天失败的原因,有人可以帮助我吗?

应用程序:

package com.example.deceunincktechniekers;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;



public class OpeningsMenu extends ListActivity {
//hier maken we de Array (lijst) met de namen die in de menu moeten komen
String classes[] = {"bezoekrapporten" ,"BTWcontrole" ,"voorbeeld3"};


// hier zetten we de layout van deze class niet gelijk aan een xml maar aan een lijst van knoppen volgens simple list item 1
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setListAdapter(new ArrayAdapter<String>(OpeningsMenu.this, android.R.layout.simple_list_item_1, classes));

}
// hier zetten we de actie als er op de lijst geklikt wordt
//
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
//
super.onListItemClick(l, v, position, id);
String positie = classes[position];
try{
Class onzeclass = Class.forName("com.example.deceunincktechniekers." + positie);
Intent onzeIntent = new Intent(OpeningsMenu.this, onzeclass);
startActivity(onzeIntent);
}catch (ClassNotFoundException e){
e.printStackTrace();
}
}

日志猫:

07-13 12:48:47.204: D/dalvikvm(785): GC_CONCURRENT freed 73K, 8% free 2768K/2984K, paused 14ms+57ms, total 148ms
07-13 12:48:47.664: I/Choreographer(785): Skipped 81 frames! The application may be doing too much work on its main thread.
07-13 12:48:47.714: D/gralloc_goldfish(785): Emulator without GPU emulation detected.
07-13 12:53:35.678: D/dalvikvm(785): newInstance failed: Lcom/example/deceunincktechniekers/bezoekrapporten; not accessible to Landroid/app/Instrumentation;
07-13 12:53:35.678: D/AndroidRuntime(785): Shutting down VM
07-13 12:53:35.678: W/dalvikvm(785): threadid=1: thread exiting with uncaught exception (group=0x40a71930)
07-13 12:53:35.738: E/AndroidRuntime(785): FATAL EXCEPTION: main
07-13 12:53:35.738: E/AndroidRuntime(785): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.deceunincktechniekers/com.example.deceunincktechniekers.bezoekrapporten}: java.lang.IllegalAccessException: access to class not allowed
07-13 12:53:35.738: E/AndroidRuntime(785): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2106)
07-13 12:53:35.738: E/AndroidRuntime(785): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
07-13 12:53:35.738: E/AndroidRuntime(785): at android.app.ActivityThread.access$600(ActivityThread.java:141)
07-13 12:53:35.738: E/AndroidRuntime(785): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
07-13 12:53:35.738: E/AndroidRuntime(785): at android.os.Handler.dispatchMessage(Handler.java:99)
07-13 12:53:35.738: E/AndroidRuntime(785): at android.os.Looper.loop(Looper.java:137)
07-13 12:53:35.738: E/AndroidRuntime(785): at android.app.ActivityThread.main(ActivityThread.java:5041)
07-13 12:53:35.738: E/AndroidRuntime(785): at java.lang.reflect.Method.invokeNative(Native Method)
07-13 12:53:35.738: E/AndroidRuntime(785): at java.lang.reflect.Method.invoke(Method.java:511)
07-13 12:53:35.738: E/AndroidRuntime(785): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
07-13 12:53:35.738: E/AndroidRuntime(785): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
07-13 12:53:35.738: E/AndroidRuntime(785): at dalvik.system.NativeStart.main(Native Method)
07-13 12:53:35.738: E/AndroidRuntime(785): Caused by: java.lang.IllegalAccessException: access to class not allowed
07-13 12:53:35.738: E/AndroidRuntime(785): at java.lang.Class.newInstanceImpl(Native Method)
07-13 12:53:35.738: E/AndroidRuntime(785): at java.lang.Class.newInstance(Class.java:1319)
07-13 12:53:35.738: E/AndroidRuntime(785): at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
07-13 12:53:35.738: E/AndroidRuntime(785): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
07-13 12:53:35.738: E/AndroidRuntime(785): ... 11 more
07-13 12:53:38.838: I/Process(785): Sending signal. PID: 785 SIG: 9

如果您需要更多信息,请询问

最佳答案

要么没有名为 com.example.deceunincktechniekers.bezoekrapporten 的类,要么不是 public,或者可能没有 public构造函数。

关于java - startactivity() 关闭应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17630421/

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