我在我的包中使用了一个库,它显示了Flickr中的图像我在清单文件中声明了它,但它仍然给出了错误
06-12 22:00:03.862: E/AndroidRuntime(15128): FATAL EXCEPTION: main
06-12 22:00:03.862: E/AndroidRuntime(15128): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.examples.youtubeapidemo/com.mani.staggeredview.demo.MainActivity}: java.lang.IllegalStateException: RequestQueue not initialized
06-12 22:00:03.862: E/AndroidRuntime(15128): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
06-12 22:00:03.862: E/AndroidRuntime(15128): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
06-12 22:00:03.862: E/AndroidRuntime(15128): at android.app.ActivityThread.access$600(ActivityThread.java:141)
06-12 22:00:03.862: E/AndroidRuntime(15128): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
06-12 22:00:03.862: E/AndroidRuntime(15128): at android.os.Handler.dispatchMessage(Handler.java:99)
06-12 22:00:03.862: E/AndroidRuntime(15128): at android.os.Looper.loop(Looper.java:137)
06-12 22:00:03.862: E/AndroidRuntime(15128): at android.app.ActivityThread.main(ActivityThread.java:5041)
06-12 22:00:03.862: E/AndroidRuntime(15128): at java.lang.reflect.Method.invokeNative(Native Method)
06-12 22:00:03.862: E/AndroidRuntime(15128): at java.lang.reflect.Method.invoke(Method.java:511)
06-12 22:00:03.862: E/AndroidRuntime(15128): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
06-12 22:00:03.862: E/AndroidRuntime(15128): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
06-12 22:00:03.862: E/AndroidRuntime(15128): at dalvik.system.NativeStart.main(Native Method)
06-12 22:00:03.862: E/AndroidRuntime(15128): Caused by: java.lang.IllegalStateException: RequestQueue not initialized
06-12 22:00:03.862: E/AndroidRuntime(15128): at com.mani.staggeredview.demo.app.StaggeredDemoApplication.getRequestQueue(StaggeredDemoApplication.java:35)
06-12 22:00:03.862: E/AndroidRuntime(15128): at com.mani.staggeredview.demo.MainActivity.onCreate(MainActivity.java:72)
06-12 22:00:03.862: E/AndroidRuntime(15128): at android.app.Activity.performCreate(Activity.java:5104)
06-12 22:00:03.862: E/AndroidRuntime(15128): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
06-12 22:00:03.862: E/AndroidRuntime(15128): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
06-12 22:00:03.862: E/AndroidRuntime(15128): ... 11 more
06-12 22:00:07.452: I/Process(15128): Sending signal. PID: 15128 SIG: 9
在清单文件中声明
<activity
android:name="com.mani.staggeredview.demo.MainActivity"
android:label="Activity from library">
</activity>
在课堂上,我称之为
import com.mani.staggeredview.demo.*;
.
.
.
.
btn_naat.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Intent myIntent = new Intent(getBaseContext(),com.mani.staggeredview.demo.MainActivity.class);
startActivity(myIntent);
}
});
答案 0 :(得分:0)
我认为您正在使用Volley
库进行联网。您似乎尚未初始化RequestQueue
对象:
if (mRequestQueue == null) {
mRequestQueue = Volley.newRequestQueue(getApplicationContext());
}
在您声明RequestQueue
对象的任何位置添加上述代码。试试这个。它应该工作。