import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
public class CallPhonetReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
String number=getResultData();
if("123456".equals(number)){
setResultData(null);
Intent intentMainActivity=new Intent(context,LostActivity.class);
intentMainActivity.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intentMainActivity);
}
}
}
清单文件:
<receiver android:name=".CallPhonetReceiver">
android.intent.action.NEW_OUTGOING_CALL"/>
receiver>
当初把receiver写错了,导致一直监听不了。。。R E C E I V E R
这样就可以了。先运行程序,然后拨打123456就可以跳到另一个activity了。