Java Android应用程序运行后显示黑屏

Java Android应用程序运行后显示黑屏,java,android,xml,eclipse,Java,Android,Xml,Eclipse,当我在Eclipse上单击Runasandroid应用程序时,控制台中将显示以下内容 [2014-06-05 20:07:18 - StudentConnect] Android Launch! [2014-06-05 20:07:18 - StudentConnect] adb is running normally. [2014-06-05 20:07:18 - StudentConnect] Performing sandhu.student.connect.SplashActivity

当我在Eclipse上单击Runasandroid应用程序时,控制台中将显示以下内容

[2014-06-05 20:07:18 - StudentConnect] Android Launch!
[2014-06-05 20:07:18 - StudentConnect] adb is running normally.
[2014-06-05 20:07:18 - StudentConnect] Performing sandhu.student.connect.SplashActivity activity launch
[2014-06-05 20:07:18 - StudentConnect] Using default Build Tools revision 19.0.0
[2014-06-05 20:07:18 - StudentConnect] Refreshing resource folders.
[2014-06-05 20:07:18 - StudentConnect] Using default Build Tools revision 19.0.0
[2014-06-05 20:07:18 - StudentConnect] Starting incremental Pre Compiler: Checking resource changes.
[2014-06-05 20:07:18 - StudentConnect] Nothing to pre compile!
[2014-06-05 20:07:18 - StudentConnect] Starting incremental Package build: Checking resource changes.
[2014-06-05 20:07:18 - StudentConnect] Using default Build Tools revision 19.0.0
[2014-06-05 20:07:18 - StudentConnect] Skipping over Post Compiler.
[2014-06-05 20:07:20 - StudentConnect] Application already deployed. No need to reinstall.
[2014-06-05 20:07:20 - StudentConnect] Starting activity sandhu.student.connect.SplashActivity on device 0f0898b2
[2014-06-05 20:07:21 - StudentConnect] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=sandhu.student.connect/.SplashActivity }
[2014-06-05 20:07:21 - StudentConnect] ActivityManager: Warning: Activity not started, its current task has been brought to the front
部署到我的手机后,它只显示一个黑屏。我最近实现了一个闪屏,但它以前工作得很好;不过,我认为这可能与问题有关。以下是我的java和xml文件:

MainActivity.java

package sandhu.student.connect;

import android.app.Activity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class MainActivity extends Activity {

    public WebView student_zangle;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);  
        WebView student_zangle = (WebView) findViewById(R.id.student_zangle);
        student_zangle.loadUrl("https://zangleweb01.clovisusd.k12.ca.us/studentconnect/");
        student_zangle.setWebViewClient(new WebViewClient());
        student_zangle.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
        WebSettings settings = student_zangle.getSettings();
        settings.setJavaScriptEnabled(true);
        settings.setBuiltInZoomControls(true);      
        settings.setLoadWithOverviewMode(true);
        settings.setUseWideViewPort(true);
    }


    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        WebView student_zangle = (WebView) findViewById(R.id.student_zangle);
        if ((keyCode == KeyEvent.KEYCODE_BACK) && student_zangle.canGoBack()) {
            student_zangle.goBack();
            return true;
        }
        else
        {
            finish();
        }
        return super.onKeyDown(keyCode, event);
    }

}
package sandhu.student.connect;


import android.os.Bundle;
import android.preference.PreferenceActivity;

public class SplashActivity extends PreferenceActivity {

    @SuppressWarnings("deprecation")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);

        addPreferencesFromResource(R.xml.prefs);
    }



 }
activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/blue"
    tools:context=".MainActivity" >

    <WebView
        android:id="@+id/student_zangle"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

</RelativeLayout>
splash_activity.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/blue"
    android:orientation="vertical" >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="250dp"
        android:layout_height="100dp"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="145dp"
        android:contentDescription="@string/zangle_logo"
        android:src="@drawable/logo" />

</RelativeLayout>

请帮我找出问题所在,或者至少给我指出正确的方向。提前感谢。

此消息:ActivityManager:警告:活动未启动,其当前任务已移至前端,这意味着adb检测到已部署相同的应用程序,因此它只需将该应用程序置于前端。 您可以尝试将其从手机中删除,或在需要重新部署应用程序时在debug it中启动


如果您发现手机上的应用程序不是最新的,请尝试清除project。

这不是错误消息,而是警告。系统试图告诉您的是:设备上的应用程序与Eclipse中的应用程序相同。由于应用程序已经在设备上运行,如果您没有更改代码,则不会进行重新编译,它不会经过卸载安装过程,系统会告诉您它不会终止并重新启动它,而是将已经运行的应用程序的活动带到前台。这很正常

如果您编辑代码并运行它,则警告将不会继续,因为应用程序将被终止、重新安装并启动


我确实收到过很多次这样的警告,我使用了一种蹩脚的技术。在任何文件的代码中的任意位置添加空格。只需保存项目并运行。然后,它将再次经历上载和安装过程。这是最简单的方法,无需实际更改任何重要的代码。

是否不需要在启动屏幕中设置ContentView?从手机中卸载应用程序,然后重新安装。清理和刷新项目,以及在手机上卸载应用程序,都无法解决黑屏问题。
06-05 20:19:46.698: E/Watchdog(817): !@Sync 1952
06-05 20:20:09.971: E/memtrack(16438): Couldn't load memtrack module (No such file or directory)
06-05 20:20:09.971: E/android.os.Debug(16438): failed to load memtrack module: -2
06-05 20:20:11.012: E/memtrack(16451): Couldn't load memtrack module (No such file or directory)
06-05 20:20:11.012: E/android.os.Debug(16451): failed to load memtrack module: -2
06-05 20:20:11.202: E/EnterpriseContainerManager(817): ContainerPolicy Service is not yet ready!!!