有没有办法根据添加到筛选列表中的手机号拦截来电/短信(拦截或解封)?
发布于 2010-03-09 14:32:39
据我所知,接听电话的应用程序不能修改。但是,请参阅How to block calls in android以获得一些创造性的建议。
似乎有一种删除短信的方法,请参阅How to delete an SMS from the inbox in Android programmatically?。
但应用程序这样做是非常值得怀疑的,因为副作用可能会很严重。确保你的用户理解这一点!最好的解决方案IMHO将是有一个单独的android版本,它支持这些儿童安全功能(我假设这就是你想使用它的目的)。
发布于 2011-03-11 12:23:59
->关于你的问题,我认为以下几点会有帮助。
package android_programmers_guide.PhoneCallReceiver;
import java.lang.reflect.Method;
import com.android.internal.telephony.ITelephony;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.widget.Toast;
public class PhoneCallReceiver extends BroadcastReceiver
{
Context context = null;
private static final String TAG = "THIRI THE WUT YEE";
private ITelephony telephonyService;
@Override
public void onReceive(Context context, Intent intent)
{
Log.v(TAG, "Receving....");
TelephonyManager telephony = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
try
{
Class c = Class.forName(telephony.getClass().getName());
Method m = c.getDeclaredMethod("getITelephony");
m.setAccessible(true);
telephonyService = (ITelephony) m.invoke(telephony);
Toast tag = Toast.makeText(context, "Call is not allowed in the meeting!!!", Toast.LENGTH_LONG);
tag.setDuration(25);
tag.show();
telephonyService.silenceRinger();
telephonyService.endCall();
}
catch (Exception e)
{
e.printStackTrace();
}
}
}->这里是接口类
package com.android.internal.telephony;
interface ITelephony
{
boolean endCall();
void answerRingingCall();
void silenceRinger();
}->清单如下
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".PhoneCall2"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name=".PhoneCallReceiver">
<intent-filter android:priority="100" >
<action android:name="android.intent.action.PHONE_STATE" />
</intent-filter>
</receiver>
</application>
<uses-sdk android:minSdkVersion="3" />
<uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
</manifest> ->老实说,我在网上找到了这段代码干杯!
发布于 2012-09-23 03:57:22
嗯,如果你正在寻找一个应用程序,在Android市场上肯定有很多来电拦截应用程序。我推荐下面的免费应用程序来做这件事和更多的事情:https://play.google.com/store/apps/details?id=cloud4apps.cBlocker
https://stackoverflow.com/questions/2406867
复制相似问题