Android 在我的应用程序上崩溃

Android 在我的应用程序上崩溃,android,Android,我撞车了: ERROR/AndroidRuntime(27007):致命异常:main 03-15 18:29:04.967:ERROR/AndroidRuntime(27007):java.lang.RuntimeException:无法销毁活动{com.TravelTop/com.TravelTop.Ego}:java.lang.NullPointerException 这是第一个活动的onCreate,当您按下按钮(fromButton)将调用另一个活动并期望返回国家名称时 @Overri

我撞车了: ERROR/AndroidRuntime(27007):致命异常:main 03-15 18:29:04.967:ERROR/AndroidRuntime(27007):java.lang.RuntimeException:无法销毁活动{com.TravelTop/com.TravelTop.Ego}:java.lang.NullPointerException

这是第一个活动的onCreate,当您按下按钮(fromButton)将调用另一个活动并期望返回国家名称时

@Override
public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);  
    setContentView(R.layout.home);

   // final int recquestCode = 0;
    final Button btnCountryfrom = (Button) findViewById(R.id.fromButton);
    btnCountryfrom.setOnClickListener(new OnClickListener()
    {

        public void onClick(View v)
        {


            Intent pingIntent = new Intent(getApplicationContext(),CountryView.class);
            pingIntent.putExtra("btnText", " ");
            pingIntent.setClass(TravelPharmacy.this, CountryView.class);
            startActivityForResult(pingIntent, RECEIVE_MESSAGE);
            Log.i("tag for easy filter in logcat 6","I am Working!!!");
            ButtonFromPressed=true;

         }



    }); 
}

在获取要在其他活动中选择的国家/地区的名称时,覆盖 onActivityResult并在按钮中设置国家名称

     @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
    super.onActivityResult(requestCode, resultCode, data);

     Button btnCountryfrom = (Button) findViewById(R.id.fromButton);


        CharSequence seq = data.getCharSequenceExtra("response");
        btnCountryfrom.setText(seq);
        ButtonFromPressed=false;



    }
}

我的第二个活动的onCreate

    @Override
public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.country);

    mListUsers = getCountry();
    lvUsers = (ListView) findViewById(R.id.countrylistView);
    lvUsers.setAdapter(new ListAdapter(this, R.id.countrylistView, mListUsers)); 



    lvUsers.setOnItemClickListener(new OnItemClickListener()
    {

        public void onItemClick(AdapterView<?> parent, View view,int position, long id)
        {



            Intent pongIntent = new Intent();

            Log.i("tag for easy filter in logcat 1", "information you provide");

            Log.i("tag for easy filter in logcat 2",mListUsers.get(position).pays);

            pongIntent.putExtra("response",mListUsers.get(position).pays);
            setResult(Activity.RESULT_OK,pongIntent);

            finish();
            Log.i("tag for easy filter in logcat 3",mListUsers.get(position).pays);



        }
     });

}
@覆盖
创建时的公共void(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.country);
mListUsers=getCountry();
lvUsers=(ListView)findViewById(R.id.countrylistView);
setAdapter(新的ListAdapter(this,R.id.countrylistView,mListUsers));
lvUsers.setOnItemClickListener(新的OnItemClickListener()
{
public void onItemClick(AdapterView父对象、视图、整型位置、长id)
{
Intent pongIntent=新Intent();
Log.i(“logcat 1中的简易过滤器标签”,“您提供的信息”);
Log.i(“Logcat2中的简易过滤器标签”,mListUsers.get(position.pays);
pongIntent.putExtra(“响应”,mListUsers.get(position.pays));
setResult(Activity.RESULT\u OK,pongIntent);
完成();
Log.i(“logcat 3中的简易过滤器标签”,mListUsers.get(position.pays);
}
});
}
我会感激你的帮助


谢谢

看起来像空指针取消引用(来自java API文档)

“当应用程序在需要对象的情况下尝试使用null时引发…”


如果看不到代码,很难说得更多。

请发布一些您认为导致此问题的代码。