Search in sources :

Example 86 with ConnectivityManager

use of android.net.ConnectivityManager in project android_frameworks_base by ResurrectionRemix.

the class AirplaneModeTile method setEnabled.

private void setEnabled(boolean enabled) {
    final ConnectivityManager mgr = (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
    mgr.setAirplaneMode(enabled);
}
Also used : ConnectivityManager(android.net.ConnectivityManager)

Example 87 with ConnectivityManager

use of android.net.ConnectivityManager in project Synthese_2BIN by TheYoungSensei.

the class ItemListActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_item_list);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    toolbar.setTitle(getTitle());
    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG).setAction("Action", null).show();
        }
    });
    View recyclerView = findViewById(R.id.item_list);
    assert recyclerView != null;
    setupRecyclerView((RecyclerView) recyclerView);
    if (findViewById(R.id.item_detail_container) != null) {
        // The detail container view will be present only in the
        // large-screen layouts (res/values-w900dp).
        // If this view is present, then the
        // activity should be in two-pane mode.
        mTwoPane = true;
    }
    model = ((Builder) getApplication()).getModel();
    model.registerObserver(this);
    ConnectivityManager connMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
    task = new MyTask();
    if (networkInfo != null && networkInfo.isConnected()) {
        //fetch data
        task.execute("http://ws.audioscrobbler.com/2.0/?method=geo.gettopartists&country=belgium&api_key=32ef5df0e36797b605e205529058f3b8&format=json&limit=" + INT);
    } else {
    //ERROR
    }
}
Also used : NetworkInfo(android.net.NetworkInfo) ConnectivityManager(android.net.ConnectivityManager) FloatingActionButton(android.support.design.widget.FloatingActionButton) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) Toolbar(android.support.v7.widget.Toolbar)

Example 88 with ConnectivityManager

use of android.net.ConnectivityManager in project Synthese_2BIN by TheYoungSensei.

the class ItemListActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_item_list);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    toolbar.setTitle(getTitle());
    View recyclerView = findViewById(R.id.item_list);
    assert recyclerView != null;
    setupRecyclerView((RecyclerView) recyclerView);
    if (findViewById(R.id.item_detail_container) != null) {
        // The detail container view will be present only in the
        // large-screen layouts (res/values-w900dp).
        // If this view is present, then the
        // activity should be in two-pane mode.
        mTwoPane = true;
    }
    ConnectivityManager connMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
    LastFMTask task = new LastFMTask();
    if (networkInfo != null && networkInfo.isConnected()) {
        //fetch data
        task.execute("http://ws.audioscrobbler.com/2.0/?method=geo.gettopartists&country=belgium&api_key=32ef5df0e36797b605e205529058f3b8&format=json&limit=" + 50);
    }
}
Also used : NetworkInfo(android.net.NetworkInfo) ConnectivityManager(android.net.ConnectivityManager) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) Toolbar(android.support.v7.widget.Toolbar)

Example 89 with ConnectivityManager

use of android.net.ConnectivityManager in project Synthese_2BIN by TheYoungSensei.

the class BusinessDayDetailFragment method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (getArguments().containsKey(ARG_ITEM_ID)) {
        // Load the dummy content specified by the fragment
        // arguments. In a real-world scenario, use a Loader
        // to load content from a content provider.
        mItem = DetailsContent.ITEM_MAP.get(getArguments().getString(ARG_ITEM_ID));
        Activity activity = this.getActivity();
        CollapsingToolbarLayout appBarLayout = (CollapsingToolbarLayout) activity.findViewById(R.id.toolbar_layout);
        if (appBarLayout != null) {
            appBarLayout.setTitle(mItem.content);
        }
    }
    this.model = ((Builder) this.getContext().getApplicationContext()).getModel();
    model.registerCompaniesObserver(this);
    ConnectivityManager connMgr = (ConnectivityManager) this.getContext().getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
    ShowMyCompaniesTask task = new ShowMyCompaniesTask();
    if (networkInfo != null && networkInfo.isConnected()) {
        task.execute();
    }
}
Also used : NetworkInfo(android.net.NetworkInfo) ConnectivityManager(android.net.ConnectivityManager) Activity(android.app.Activity) CollapsingToolbarLayout(android.support.design.widget.CollapsingToolbarLayout)

Example 90 with ConnectivityManager

use of android.net.ConnectivityManager in project Synthese_2BIN by TheYoungSensei.

the class BusinessDayListActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_businessday_list);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    toolbar.setTitle(getTitle());
    View recyclerView = findViewById(R.id.businessday_list);
    assert recyclerView != null;
    setupRecyclerView((RecyclerView) recyclerView);
    if (findViewById(R.id.businessday_detail_container) != null) {
        // The detail container view will be present only in the
        // large-screen layouts (res/values-w900dp).
        // If this view is present, then the
        // activity should be in two-pane mode.
        mTwoPane = true;
    }
    DetailsContent.reinitialize();
    ConnectivityManager connMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
    LastFMTask task = new LastFMTask();
    if (networkInfo != null && networkInfo.isConnected()) {
        task.execute();
    }
    this.model = ((Builder) getApplication()).getModel();
}
Also used : NetworkInfo(android.net.NetworkInfo) ConnectivityManager(android.net.ConnectivityManager) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View) Toolbar(android.support.v7.widget.Toolbar)

Aggregations

ConnectivityManager (android.net.ConnectivityManager)379 NetworkInfo (android.net.NetworkInfo)275 Context (android.content.Context)14 TelephonyManager (android.telephony.TelephonyManager)14 Intent (android.content.Intent)11 RemoteException (android.os.RemoteException)11 Test (org.junit.Test)11 WifiManager (android.net.wifi.WifiManager)9 Method (java.lang.reflect.Method)9 Network (android.net.Network)8 IOException (java.io.IOException)8 PackageManager (android.content.pm.PackageManager)7 UserManager (android.os.UserManager)7 SharedPreferences (android.content.SharedPreferences)6 NetworkCapabilities (android.net.NetworkCapabilities)6 Activity (android.app.Activity)5 ApplicationInfo (android.content.pm.ApplicationInfo)5 IPackageManager (android.content.pm.IPackageManager)5 PackageInfo (android.content.pm.PackageInfo)5 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)5