I'm trying to call this class below from an AlertDialog
.. I tried Intent
but I always get exception
.
code that calls Switchoff class:
Intent intent = new Intent(Premium.this, Switchoff.class );
startActivity( intent );
The class I'm trying to call:
public class Switchoff extends AppCompatPreferenceActivity{
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final SwitchPreference vibrateSwitch = (SwitchPreference) findPreference( getString( R.string.pref_vibrate_switch_enabled ) );
vibrateSwitch.setChecked(false);
}
}
the error:
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Context.getPackageName()' on a null object reference
at android.content.ContextWrapper.getPackageName(ContextWrapper.java:142)
PS: - I need to keep both findPreference(), and onCreate() method - Both class (Premium.class, Switchoff.class) are registed in the Manifest file
THANK YOU FOR EVERY HELP!