我无法解决这个问题,因为我在 AsyncTask 时遇到了这个问题,并且在postexecute上,在意图调用期间它发生了。
@Override
protected void onPostExecute(Void result) {
super.onPostExecute(result);
// Dismiss the progress dialog
try {
Intent isplash= new Intent(Splash.this,MainPage.class);
startActivity(isplash);
finish();
} catch (Exception e) {
e.printStackTrace();
}
}
在menefest.xml中
<activity android:name=".MainPage"
android:screenOrientation="landscape"></activity>
并遇到错误:
Unable to resolve superclass of Lco/test/MainPage; (130)
Link of class 'Lco/test/MainPage;' failed
Could not find class 'co.test.MainPage', referenced from method co.test.Splash$GetData.onPostExecute
VFY: unable to resolve const-class 320 (Lco/test/MainPage;) in Lco/test/Splash$GetData;
和
FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: co.test.MainPage
at co.test.Splash$GetData.onPostExecute(Splash.java:1732)
at co.test.Splash$GetData.onPostExecute(Splash.java:1)
at android.os.AsyncTask.finish(AsyncTask.java:602)
at android.os.AsyncTask.access$600(AsyncTask.java:156)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:615)
问题:调用Intent时。为什么这个?我不知道?? 在google上搜索很多时间,但找不到任何合适的解决方案。
答案 0 :(得分:2)
代码可能看起来像这样,
public class MyAsyncTask extends AsyncTask {
Context context;
private MyAsyncTask(Context context) {
this.context = context.getApplicationContext();
}
@Override
protected Object doInBackground(Object... params) {
...
}
@Override
protected void onPostExecute(List<VideoDataDescription> result) {
super.onPostExecute(result);
MainActivity.progressDialog.dismiss();
context.startActivity(new Intent(context, ResultsQueryActivity.class));
}
}
你这样称呼它:
new MyAsyncTask(context).execute();
答案 1 :(得分:0)
请确保如果活动类位于不同的包中,则包名称必须包含在清单文件中,如下所示:
<activity android:name="co.test.MainPage"
android:screenOrientation="landscape"></activity>
&#13;