2010-03-09 75 views

回答

5

據我所知接收呼叫的應用程序無法修改。 但是,請參閱How to block calls in android獲取一些創意建議。

似乎有刪除短信的步驟見 How to delete an SMS from the inbox in Android programmatically?

但是,應用程序執行此操作的可能性很大,因爲副作用可能很嚴重。確保你的用戶瞭解這一點! 最好的解決方案恕我直言,將有一個單獨的Android構建支持這些兒童安全功能(我認爲這是你想用它)。

7

---->對於您的問題,我認爲以下將有所幫助。

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> 

--->真的,I」已經在網上找到這個代碼 乾杯!

+0

似乎是內部API – 2014-09-26 05:15:50

+0

的缺口劈它工作正常。謝謝 – spr 2015-07-20 16:29:29