我想爲我創建的庫創建一個測試應用程序。當我的圖書館被調用時,它創建一個意圖並開始一個活動。運行時錯誤創建意圖
intent = new Intent(getApplicationContext(), video_on_load.class);
myLib.this.startActivity(intent);
我的程序看起來我的程序在創建新的Intent時崩潰了。我想,爲什麼會發生這種事,我看到在我的應用我有過活動的AndroidManafest,所以我加了下面一行到我的清單:
activity android:name="com.example.myLib.video_on_load"></activity>
但是我的應用程序與仍然會崩潰消息「不幸的是,TestApp已經停止。」我不確定如何繼續。我對android編程相當陌生,所以它可能是我錯過的簡單東西。讓我知道你是否需要其他任何有助於調試此問題的信息。
我video_on_load類如下:
public class video_on_load extends Activity {
private RelativeLayout layout;
private ProgressBar progressBar;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.video_on_load);
layout = (RelativeLayout) findViewById(R.id.video_onLoad_layout);
progressBar = (ProgressBar) findViewById(R.id.video_onLoad_progress);
}
編輯:
培訓相關的logcat:
12-28 17:53:23.824: E/AndroidRuntime(25042): java.lang.NullPointerException
12-28 17:53:23.824: E/AndroidRuntime(25042): at android.content.ContextWrapper.getPackageName(ContextWrapper.java:135)
12-28 17:53:23.824: E/AndroidRuntime(25042): at android.content.ComponentName.<init>(ComponentName.java:75)
12-28 17:53:23.824: E/AndroidRuntime(25042): at android.content.Intent.<init>(Intent.java:3491)
video_on_load.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/video_onLoad_layout" >
<ProgressBar android:id="@+id/video_onLoad_progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
style="@android:style/Widget.ProgressBar.Large" />
</RelativeLayout>
謝謝
全能的Logcat告訴你什麼? – ninetwozero