working studio settitle programacion not móviles getsupportactionbar desarrollo curso aplicaciones android crash

studio - Excepción NULL en mi programa de Android



set title toolbar fragment android (0)

Tengo un accidente:

03-16 17:47:57.058: ERROR/AndroidRuntime(609): FATAL EXCEPTION: main 03-16 17:47:57.058: ERROR/AndroidRuntime(609): java.lang.RuntimeException: Unable to destroy activity {com.TravelPharmacy/com.TravelPharmacy.CountryView}: java.lang.NullPointerException 03-16 17:47:57.058: ERROR/AndroidRuntime(609): at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:2636) 03-16 17:47:57.058: ERROR/AndroidRuntime(609): at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:2654) 03-16 17:47:57.058: ERROR/AndroidRuntime(609): at android.app.ActivityThread.access$2100(ActivityThread.java:117) 03-16 17:47:57.058: ERROR/AndroidRuntime(609): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:961) 03-16 17:47:57.058: ERROR/AndroidRuntime(609): at android.os.Handler.dispatchMessage(Handler.java:99) 03-16 17:47:57.058: ERROR/AndroidRuntime(609): at android.os.Looper.loop(Looper.java:123) 03-16 17:47:57.058: ERROR/AndroidRuntime(609): at android.app.ActivityThread.main(ActivityThread.java:3647) 03-16 17:47:57.058: ERROR/AndroidRuntime(609): at java.lang.reflect.Method.invokeNative(Native Method) 03-16 17:47:57.058: ERROR/AndroidRuntime(609): at java.lang.reflect.Method.invoke(Method.java:507) 03-16 17:47:57.058: ERROR/AndroidRuntime(609): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) 03-16 17:47:57.058: ERROR/AndroidRuntime(609): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 03-16 17:47:57.058: ERROR/AndroidRuntime(609): at dalvik.system.NativeStart.main(Native Method) 03-16 17:47:57.058: ERROR/AndroidRuntime(609): Caused by: java.lang.NullPointerException 03-16 17:47:57.058: ERROR/AndroidRuntime(609): at com.TravelPharmacy.CountryView.onDestroy(CountryView.java:117) 03-16 17:47:57.058: ERROR/AndroidRuntime(609): at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:2623) 03-16 17:47:57.058: ERROR/AndroidRuntime(609): ... 11 more

Esa es la actividad onCreate of First, cuando presiona el botón (fromButton) que llamará a la otra actividad y espera recuperar el nombre del país.

@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; } }); }

cuando recupere el nombre del país que se seleccionará en la otra actividad, anule OnActivityResult y establezca el nombre del país en el botón

@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; } }

la onCreate de mi segunda actividad

@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); } }); }

agradeceré ayuda !!!

¡Gracias!