喵呜,好烦,又cannont resolve,在这种情况下遇到的
Intent intent = new Intent(this,emergencyIntent.class);、、
解决:
Intent intent = new Intent(MainActivity.this,emergencyIntent.class);
原因:
The error is because you are writing it in public void onClick(View v)
, where 'this
' will mean instance of anonymous class that implements View.OnClickListener
. while first parameter in Intent constructor Intent(Context context, Class<?> cls)
requires Activity context.