Requirement:
Block incoming and out going calls.
Steps:
Register a broadcast receiver to monitor calls.
In AndroidManifest.xml file write:
<receiver android:name="MyPhoneReceiver"> <intent-filter android:priority="100"> <action android:name="android.intent.action.PHONE_STATE"/> <action android:name="android.intent.action.NEW_OUTGOING_CALL"/> </intent-filter> </receiver>
Create a broadcast Receiver to catch the "call" related broadcast.
public class ProcessCall extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { //Create object of Telephony Manager class. TelephonyManager telephony = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); //Assign a phone state listener. CustomPhoneStateListener customPhoneListener = new CustomPhoneStateListener (context); telephony.listen(customPhoneListener, PhoneStateListener.LISTEN_CALL_STATE); } }Create a custom phone state listener.
import java.lang.reflect.Method; import android.content.Context; import android.telephony.PhoneStateListener; import android.telephony.TelephonyManager; import com.CallLogApp.helper.BlockNumberHelper; import com.CallLogApp.util.UDF; import com.android.internal.telephony.ITelephony; public class CustomPhoneStateListener extends PhoneStateListener { Context context; public CustomPhoneStateListener(Context context) { super(); this.context = context; } @Override public void onCallStateChanged(int state, String callingNumber) { super.onCallStateChanged(state, callingNumber); switch (state) { case TelephonyManager.CALL_STATE_IDLE: break; case TelephonyManager.CALL_STATE_OFFHOOK: //handle out going call endCallIfBlocked(callingNumber); break; case TelephonyManager.CALL_STATE_RINGING: //handle in coming call endCallIfBlocked(callingNumber); break; default: break; } } private void endCallIfBlocked(String callingNumber) { try { // Java reflection to gain access to TelephonyManager's // ITelephony getter TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); c = Class.forName(tm.getClass().getName()); Method m = c.getDeclaredMethod("getITelephony"); m.setAccessible(true); com.android.internal.telephony.ITelephony telephonyService = (ITelephony) m.invoke(tm); telephonyService = (ITelephony) m.invoke(tm); // telephonyService.silenceRinger(); telephonyService.endCall(); } catch (Exception e) { e.printStackTrace(); } } }
Pls send for me completed source code, thanks
ReplyDeletetoannd@hqsoft.com.vn
Good tutorial i like it
ReplyDeletePlease send me Actual Code
ReplyDeleteThanks for it :)
Can you please send me the entire source code as zip?
ReplyDeleteThanks,
michael.hanna@utexas.edu
can you please send complete source code as rar file?
ReplyDeletekrunal11400@gmail.com
thanks
could you plz send source code to sarathi1989@gmail.com
ReplyDeletecould you plz send source code to sarathi1989@gmail.com
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteactually my code is working but my phone all outgoing call rejected
ReplyDeleteCan you please send me the entire source code as zip? at neethupbaby95@gmail.com
ReplyDeleteCan you send me the entire source code please? rauteru@gmail.com
ReplyDeletecan you please send complete source code? malikneha747@gmail.com
ReplyDeleteFootball today happens to be a whole lot more than what goes on on the field of play. It has definitely become more than just a game, even metamorphosed in to a religion for some but that would not be my concern today, rather I would be particularly more concerned about the politics behind the game. It has become surrounded with so much intrigues that one is left wondering about what may happen next. Dwelling on the politics of the game might even sound a bit ambiguous because we are almost less concerned about the elections or who gets put in what office or not, but the maverick side to this whole free business calls called soccer.
ReplyDeleteHi,
ReplyDeletecan you pls send me complete project? iiec@seznam.cz
Thx
Can you please send me the entire code to seguharshitha@gmail.com
ReplyDeleteCan you please send me the source code for the project to ranaamin15544@gmail.com
ReplyDeleteITelephony cannot resolve .Please send me source code sandun.jaya@gmail.com
ReplyDeleteMicrosoft, the leading software developer has given mobile phone users a lot of free Windows phone apps, one of them is the Sudoku app. For centuries, Sudoku was only printed in traditional newspapers and people couldn't wait for the next day's paper to fill in the game at the last pages of the newspapers. But in this era of advanced technology, you can play Sudoku at any time you want and frequently as you desire. Free Windows phone Sudoku app is now available to you from Windows phone free app market Check This Out
ReplyDeleteITelephony cannot resolve .Please send me source code murugammalvalli10@gmail.com
ReplyDeleteI real glad to find this web site on bing, just what I was searching for : D likewise saved to bookmarks . 토토사이트
ReplyDeleteIt is especially decent, though look into the tips during this home address. One Shot Keto is fundraising for Pips Hope & Support
ReplyDeleteI like this site its a master peace ! Glad I detected this on google . buy hydrocodone online
ReplyDeleteJust wanna comment that you have a very nice site, I the style and design it actually stands out. GLD Partners
ReplyDeleteSpot lets start work on this write-up, I truly feel this fabulous website requirements a great deal more consideration. I’ll likely to end up once more to study additional, many thanks for that info. facebook login
ReplyDeleteIf you are thinking about purchasing a security camera, it's important to cover all the different types of cameras. This article covers the benefits and drawbacks of c-mount security cameras. how to build a mini spy camera
ReplyDeleteI’ve read a few just right stuff here. Definitely worth bookmarking for revisiting. I wonder how a lot effort you put to create this type of excellent informative site. buy steroids
ReplyDeletedog crates made from ABS Plastic can withstand those aggressive dogs” workout clothes
ReplyDeleteI just done mine and that i was looking for several design suggestions and you afflicted me with a few. rapid application development methodology
ReplyDeleteI was suggested this blog by way of my cousin. I’m no longer sure whether or not this put up is written by him as nobody else realize such detailed about my trouble. You’re wonderful! Thanks! buy steroids online
ReplyDeleteThe the next occasion Someone said a blog, I really hope who’s doesnt disappoint me about this blog. After all, I know it was my choice to read, but I just thought youd have some thing intriguing to talk about. All I hear is really a number of whining about something you could fix in case you werent too busy seeking attention. buy hgh
ReplyDeletewell of course, everyone loves to get rich but not everyone would love to do hard work” buy hgh
ReplyDeletei like war movies and inglourious basterds is one of the movies that i really love,, wavob.com
ReplyDeletebuy-ritalin-20mg-online
ReplyDeletebuy-ritalin-60mg-online
buy-ritalin-30mg-online
buy-ritalin-10mg-online
buy-stromectol-3mg-online
buy-stromectol-6mg-online