Click here to Skip to main content
15,896,402 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi

i use interface com.android.internal.telephony.ITelephony
but crash my project.

How can reject a call when the phone ring(reject with a text message) using the official Android SDK?
Posted

1 solution

This Worked For Me
Try This
Code


Solution by Bharat NA Parsiya
if it Works for you please vote for me
 
Share this answer
 
Comments
user1992 1-Dec-13 9:58am    
Thanks bharat Parsiya,

I try this example and my code has crash. I think that the problem is because i use:
( https://devmaze.wordpress.com/2011/01/18/using-com-android-internal-part-1-introduction/)
import com.android.internal.telephony.ITelephony;
Do you have in mind another solution for this problem ??
Maybe by using official android SDK?
user1992 1-Dec-13 14:54pm    
how include onReceive() in my code so that when call incoming have to be reject with a automatic message.??

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

TelephonyManager telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);

PhoneStateListener callStateListener = new PhoneStateListener() {
public void onCallStateChanged(int state, String incomingNumber)
{
if(state==TelephonyManager.CALL_STATE_RINGING)
{

Toast.makeText(getApplicationContext(),"Phone Is Riging", Toast.LENGTH_LONG).show();
contactExists(getApplicationContext(),incomingNumber);



}
if(state==TelephonyManager.CALL_STATE_OFFHOOK)
{
Toast.makeText(getApplicationContext(),"Phone is Currently in A call", Toast.LENGTH_LONG).show();
}

if(state==TelephonyManager.CALL_STATE_IDLE)
{
Toast.makeText(getApplicationContext(),"phone is neither ringing nor in a call", Toast.LENGTH_LONG).show();
}
}
};
telephonyManager.listen(callStateListener,PhoneStateListener.LISTEN_CALL_STATE);

}




public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900