Android 第一行代码

日志文件如下:
07- ::36.265 -/stuapplication.pla.edu.cn.fragmentbestpractice W/dalvikvm﹕ VFY: unable to find class referenced in signature (Landroid/os/PersistableBundle;)
- ::36.265 -/stuapplication.pla.edu.cn.fragmentbestpractice I/dalvikvm﹕ Could not find method android.support.v7.app.AppCompatActivity.onCreate, referenced from method stuapplication.pla.edu.cn.fragmentbestpractice.NewsContentActivity.onCreate
- ::36.265 -/stuapplication.pla.edu.cn.fragmentbestpractice W/dalvikvm﹕ VFY: unable to resolve virtual method : Landroid/support/v7/app/AppCompatActivity;.onCreate (Landroid/os/Bundle;Landroid/os/PersistableBundle;)V
- ::36.265 -/stuapplication.pla.edu.cn.fragmentbestpractice D/dalvikvm﹕ VFY: replacing opcode 0x6f at 0x0000
                     
相关代码:

public class NewsTitleFragment extends Fragment implements AdapterView.OnItemClickListener {

.....
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
News news = (News) newsArrayList.get(position);
if (isTwoPageModel){
Log.v("NewsTitleFragment","Sorry, pad screen adapter not complete");
}else {
NewsContentActivity .actionStart(getActivity(), news.getTitle(), news.getContent());
}
}
.....
}
public class NewsContentActivity extends AppCompatActivity {
public static void actionStart(Context context, String title, String content){
Intent intent = new Intent(context,NewsContentActivity.class);
intent.putExtra("title", title);
intent.putExtra("content", content);
context.startActivity(intent);
Log.v("NewsContentActivity", "startActivity");
}
....
}

最终执行时,程序没有执行NewsContentActivity 的onCreate方法。

在重写onCreate方法时选择了

import android.app.Activity;

包中的

@Override
public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) {
super.onCreate(savedInstanceState, persistentState);
}

方法,导致了日志中的:

Could not find method android.support.v7.app.AppCompatActivity.onCreate
情况。
上一篇:使用GIT来管理代码的心得


下一篇:JVM基础系列第10讲:垃圾回收的几种类型