实际上,在我的应用程序中,我想在我的手机拨打任何电话时发送一条消息......这里的应用程序安装时间要求提供父母号码及其号码从我的第一个活动发送到广播接收器活动......它在那里接收到敬酒值..但是当我打电话时,它的值更改为null ...有人可以帮助我在电话通话时访问该值..有可能吗?如何..谢谢我的代码如下.. .
在我的第一个活动中向广播接收器发送值:
try
{
Toast.makeText(getApplicationContext(), "try", Toast.LENGTH_LONG).show();
Intent in = new Intent("my.action.string");
in.putExtra("parent", PARENT);//this string sending to broadcast receiver
sendBroadcast(in);
}
catch (Exception e)
{
// TODO: handle exception
e.printStackTrace();
}
我的广播接收器是:
public class myBroadcast extends BroadcastReceiver
{
String out_number;
String myparent;
@Override
public void onReceive(Context context, Intent intent)
{
// TODO Auto-generated method stub
myparent = intent.getExtras().getString("parent"); //this sting access the number first and then change to null at making phone call
final String my=myparent;
Toast.makeText(context, "broadcst"+myparent, Toast.LENGTH_LONG).show();
if (intent.getAction().equals("android.intent.action.NEW_OUTGOING_CALL"))
{
out_number=intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
Toast.makeText(context, "broadcst"+my+" "+out_number, Toast.LENGTH_LONG).show();
SmsManager sm=SmsManager.getDefault();
sm.sendTextMessage(myparent, "5554", "calling..to"+myparent, null, null); //5554 is my emulator number to check its in emulator
Toast.makeText(context, "send"+out_number, Toast.LENGTH_SHORT).show();
}
}
}