这是我有这么远,但没有任何反应,当我输入拨号这个组合
公共类DialReceiver扩展的BroadcastReceiver
{
@覆盖
公共无效的onReceive(上下文的背景下,最终的意图意图){
如果(intent.getAction()。等于(android.content.Intent.ACTION_NEW_OUTGOING_CALL)){
。字符串phoneNumber的= intent.getExtras()的getString(android.content.Intent.EXTRA_PHONE_NUMBER);
如果(phoneNumber.equals(*#588637#)){
意图intent1 =新的意图(背景下,Activity.class);
intent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent1);
}
}
}
}
和在androidmanifest
<接收器
机器人:名称=。receiver.DialReceiver
机器人:出口=真
机器人:工艺=:背景
工具:忽略=ExportedReceiver>
<意向滤光器>
<作用机器人:名称=android.intent.action.NEW_OUTGOING_CALL/>
<类机器人:名称=android.intent.category.DEFAULT/>
&所述; /意图滤光器>
< /接收器>
解决方案
试着用这些小的变化。
字符串phoneNumber的= intent.getExtras.getString(Intent.EXTRA_PHONE_NUMBER);
如果(phoneNumber.equals(*#588637#)){
//做你的东西
}
和别忘了加入这一行你Manifest.xml文件
<使用-权限的Android:名称=android.permission.PROCESS_OUTGOING_CALLS>
也可能有帮助的。
http://android.programmerguru.com/simple-dialer-application/ http://tikuflower.blogspot.com/2011/12/android.htmlThis is what I have so far but nothing happens when I input this combination in dialer
public class DialReceiver extends BroadcastReceiver
{
@Override
public void onReceive(Context context, final Intent intent) {
if (intent.getAction().equals(android.content.Intent.ACTION_NEW_OUTGOING_CALL)) {
String phoneNumber = intent.getExtras().getString( android.content.Intent.EXTRA_PHONE_NUMBER );
if(phoneNumber.equals("*#588637#")) {
Intent intent1 = new Intent(context , Activity.class);
intent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK );
context.startActivity(intent1);
}
}
}
}
and in androidmanifest
<receiver
android:name=".receiver.DialReceiver"
android:exported="true"
android:process=":background"
tools:ignore="ExportedReceiver" >
<intent-filter>
<action android:name="android.intent.action.NEW_OUTGOING_CALL" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
解决方案
Try with these small changes..
String phoneNumber = intent.getExtras.getString("Intent.EXTRA_PHONE_NUMBER");
if(phoneNumber.equals("*#588637#")) {
//do your stuff
}
And do not forget to add this line in your Manifest.xml file
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS">
Also may find helpful..
http://android.programmerguru.com/simple-dialer-application/ http://tikuflower.blogspot.com/2011/12/android.html