当电话状态从振铃转为空闲时,我需要打电话给活动。但是它说构造函数Intent(MyPhoneStateListener,Class)是未定义的。如何调用活动。
public class MyPhoneStateListener extends PhoneStateListener {
//static String org="";
public void onCallStateChanged(int state,String incomingNumber){
switch(state){
case TelephonyManager.CALL_STATE_IDLE:
Log.d("DEBUG", "IDLE");
// MissedCall ms=new MissedCall();
Intent missintent=new Intent(this,MissedCall.class);
startActivity(missintent);
break;
case TelephonyManager.CALL_STATE_OFFHOOK:
Log.d("DEBUG", "OFFHOOK");
break;
case TelephonyManager.CALL_STATE_RINGING:
Log.d("DEBUG", "RINGING");
break;
}
}
}
最佳答案
您可以这样调用活动:
Intent missintent= new Intent(context, MissedCall.class);
missintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(missintent);