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