Back to project page smsproxy.
The source code is released under:
Copyright (c) 2012 Kei Nakazawa Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Softw...
If you think the Android project smsproxy listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package jp.muo.smsproxy; /* w w w . j a v a 2 s.co m*/ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.telephony.PhoneStateListener; import android.telephony.TelephonyManager; public class RingingReceiver extends BroadcastReceiver { @Override public void onReceive(final Context context, Intent intent) { BatteryLevelObserver.updateStatus(context); final TelephonyManager telephony = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); PhoneStateListener ringingListener = new PhoneStateListener() { @Override public void onCallStateChanged(int state, String number) { if (state == TelephonyManager.CALL_STATE_RINGING) { SmsProxyManager mgr = new SmsProxyManager(context); String msgText = String.format(context.getString(R.string.sms_on_call), (number != null && number != "") ? number : context.getString(R.string.subscriber_unknown)); mgr.send(SmsProxyManager.Mode.CALL, msgText); } telephony.listen(this, PhoneStateListener.LISTEN_NONE); } }; telephony.listen(ringingListener, PhoneStateListener.LISTEN_CALL_STATE); } }