0
实际上在我的应用程序我想发送消息时,我的手机打任何电话......这里的应用程序安装时间问父母号码和它的号码从我的第一次活动发送到广播接收器的活动......它在那里接收并烘烤价值......但是当我拨打电话时它的值变为空......任何人都可以帮助我访问那个值手机通话时间..是有可能?? how..thank你我的代码如下......我可以从我的活动发送价值广播接收器,但我不能长时间使用它
在我的第一个活动发送值广播接收机:
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();
}
}
}
感谢您的answer..but其实我在我的那个号码,我想在做电话广播接收机内部访问另一个活动得到了许多.. .how其可能 – ishaque 2013-02-13 05:04:38
哇..我解决了我的问题,我可以通过数据库发送值,我可以访问任何时间在广播接收器.....谢谢你的所有 – ishaque 2013-02-16 07:29:27