小编Sam*_*han的帖子

如何使用socks配置Android SDK管理器?

Android SDK管理器()的默认代理是HTTP,但问题是如何将它与SOCKS一起使用(我的操作系统是Windows 7)?

java sdk proxy android socks

5
推荐指数
1
解决办法
1535
查看次数

如何在BroadcastReceiver中直接使用方法"getSystemService"?

我遇到了这个问题:getSystemServiceContext类中定义,所以我假设它在调用时调用context.getSystemService.我无法理解以下getSystemService直接调用的代码BroadcastReceiver.我运行代码,没有错误显示!

代码:

 public class MainActivity extends Activity {
    ……
 class NetworkChangeReceiver extends BroadcastReceiver {
    @Override
  public void onReceive(Context context, Intent intent) {
    ConnectivityManager connectionManager = (ConnectivityManager)
    getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo networkInfo = connectionManager.getActiveNetworkInfo();
    if (networkInfo != null && networkInfo.isAvailable()) 
    {
    Toast.makeText(context, "network is available",
    Toast.LENGTH_SHORT).show();
    } else {
    Toast.makeText(context, "network is unavailable",
    Toast.LENGTH_SHORT).show();
    }
   }
 }
}
Run Code Online (Sandbox Code Playgroud)

java android android-intent android-activity android-broadcast

2
推荐指数
1
解决办法
3287
查看次数