为了账号安全,请及时绑定邮箱和手机立即绑定

下面代码中toast.maketext()的contex参数的值是从哪里传进去的呢

下面代码中toast.maketext()的contex参数的值是从哪里传进去的呢

道可道非常道 2016-08-23 09:37:08
public class MainActivity extends Activity {private IntentFilter intentFilter;private NetworkChangeReceiver networkChangeReceiver;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);intentFilter = new IntentFilter();intentFilter.addAction("android.net.conn.CONNECTIVITY_CHANGE");networkChangeReceiver = new NetworkChangeReceiver();registerReceiver(networkChangeReceiver, intentFilter);}@Overrideprotected void onDestroy() {super.onDestroy();unregisterReceiver(networkChangeReceiver);}class NetworkChangeReceiver extends BroadcastReceiver {@Overridepublic void onReceive(Context context, Intent intent) {Toast.makeText(context, "network changes",Toast.LENGTH_SHORT).show();}}}
查看完整描述

目前暂无任何回答

  • 0 回答
  • 0 关注
  • 2209 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信