可能重复:
将值从活动传递到广播接收器并从广播接收器启动服务
我创建了一个将来电号码发送到蓝牙的应用程序,我想将管理员号码从活动传递给接收器。我该怎么做?
public void onResume() {
super.onResume();
registerReceiver(new IncomingCallReceiver(), new intentFilter("android.intent.action.PHONE_STATE"));
@Override
public void onReceive(Context context, Intent intent) {
Bundle bundle = intent.getExtras();
String msg2 = intent.getStringExtra("admin_no");
if(null == bundle)
return;
Log.i("IncomingCallReceiver",bundle.toString());
String state = bundle.getString(TelephonyManager.EXTRA_STATE);
Log.i("IncomingCallReceiver","State: "+ state);
if(state.equalsIgnoreCase(TelephonyManager.EXTRA_STATE_RINGING))
{
String phonenumber = bundle.getString(TelephonyManager.EXTRA_INCOMING_NUMBER);