0

我有以下活动,当调用 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

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

4

3 回答 3

1

你的日志说

java.lang.IllegalAccessException 不允许访问类

可能是类,名为

com.example.deceunincktechniekers。+ 职位

没有公共构造函数

于 2013-07-13T13:04:10.820 回答
1

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

于 2013-07-13T13:04:26.523 回答
0

我遇到过同样的问题; 我检查了 AndroidManifest.xml 并且我想用startActivity(Intent)调用的活动丢失了。添加活动后(检查下方),我可以调用我的活动(条目):

于 2019-11-18T20:37:41.703 回答