Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/214.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android:无法从内部类启动新活动_Android_Android Intent_Android Activity - Fatal编程技术网

Android:无法从内部类启动新活动

Android:无法从内部类启动新活动,android,android-intent,android-activity,Android,Android Intent,Android Activity,安卓:有人帮忙: 我注意到以前有人问过这样的问题,但答案对我的情况没有帮助;我需要从内部发起一项新活动 类,但我得到的只是下面的错误: 04-05 15:00:43.851: E/AndroidRuntime(3288): Caused by: java.lang.InstantiationException: com.school.School$StudentProfile 以下是我的代码片段: public class School extends Activity{ ProgressDi

安卓:有人帮忙: 我注意到以前有人问过这样的问题,但答案对我的情况没有帮助;我需要从内部发起一项新活动 类,但我得到的只是下面的错误:

04-05 15:00:43.851: E/AndroidRuntime(3288): Caused by: java.lang.InstantiationException: com.school.School$StudentProfile
以下是我的代码片段:

public class School extends Activity{
ProgressDialogue progressDialogue;

protected WebViewTask _webTask;

String path = "http://www.school.com/student/"; 

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


    progressDialogue = new ProgressDialogue(School.this);

    _webTask = new WebViewTask();
    _webTask.execute();

}   

//rest of the code

  /** The inner class */

public class StudentProfile {
    Context context;


    /** Instantiate the interface and set the context */

    public StudentProfile(Context c) {
         context=c;
        }

    /** launch student activity */
    public void lauchProfile() {

         School.this.startActivity(new Intent(School.this, StudentProfile.class));
        //Intent intent = new Intent(School.this, StudentProfile.class);

        //startActivity(intent);

    }
}   

void webView(){
    String url = path +"student.php";   

    WebView wv = (WebView) findViewById(R.id.trivia_webview);
    WebSettings webSettings = wv.getSettings();
    webSettings.setJavaScriptEnabled(true);

    wv.addJavascriptInterface(new StudentProfile (this), "Student");

    wv.loadUrl(url);

    wv.setWebViewClient(new WebViewClient() {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            // open URL in the web view itself
            if (url.contains(url))
                return super.shouldOverrideUrlLoading(view, url);
            // open URL in an external web browser
            else {

                return true;
            }
        }
    });
}

// rest of the code

注意:web视图上有一个“学生”按钮,用于启动StudentProfile活动。

您的
学生档案
不是
活动,因此您不能以这种方式启动它。它需要是一个单独的类,并在
AndroidManifest.xml

中声明。将其更改为StudentProfile类中的上下文。从何处调用“StudentProfile(context c)”构造函数?