List of usage examples for android.net ConnectivityManager CONNECTIVITY_ACTION
String CONNECTIVITY_ACTION
To view the source code for android.net ConnectivityManager CONNECTIVITY_ACTION.
Click Source Link
From source file:com.wondertoys.pokevalue.utils.AutoUpdateApk.java
private void setupVariables(Context ctx) { context = ctx;/*from w w w. j a va 2s.co m*/ packageName = context.getPackageName(); preferences = context.getSharedPreferences(packageName + "_" + TAG, Context.MODE_PRIVATE); device_id = crc32(Secure.getString(context.getContentResolver(), Secure.ANDROID_ID)); last_update = preferences.getLong("last_update", 0); NOTIFICATION_ID += crc32(packageName); // schedule.add(new ScheduleEntry(0,24)); ApplicationInfo appinfo = context.getApplicationInfo(); if (appinfo.icon != 0) { appIcon = appinfo.icon; } else { Log_w(TAG, "unable to find application icon"); } if (appinfo.labelRes != 0) { appName = context.getString(appinfo.labelRes); } else { Log_w(TAG, "unable to find application label"); } if (new File(appinfo.sourceDir).lastModified() > preferences.getLong(MD5_TIME, 0)) { preferences.edit().putString(MD5_KEY, MD5Hex(appinfo.sourceDir)).commit(); preferences.edit().putLong(MD5_TIME, System.currentTimeMillis()).commit(); String update_file = preferences.getString(UPDATE_FILE, ""); if (update_file.length() > 0) { if (new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS) + "/" + update_file).delete()) { preferences.edit().remove(UPDATE_FILE).remove(SILENT_FAILED).commit(); } } } raise_notification(); if (haveInternetPermissions()) { context.registerReceiver(connectivity_receiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION)); } }
From source file:com.DGSD.DGUtils.Http.BetterHttp.java
public static void setContext(Context context) { if (appContext != null) { return;/*w w w .jav a 2 s. co m*/ } appContext = context.getApplicationContext(); appContext.registerReceiver(new ConnectionChangedBroadcastReceiver(), new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION)); }
From source file:com.kentph.ttcnextbus.NetworkActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Register BroadcastReceiver to track connection changes. IntentFilter filter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION); receiver = new NetworkReceiver(); this.registerReceiver(receiver, filter); /*//w w w .ja v a 2 s .c o m * Create a new location client, using the enclosing class to * handle callbacks. */ mLocationClient = new LocationClient(this, this, this); }
From source file:com.example.MobileSchoolDev.Utils.AutoUpdateApk.java
private void setupVariables(Context ctx) { context = ctx;/*from ww w . j ava 2 s . c o m*/ packageName = context.getPackageName(); preferences = context.getSharedPreferences(packageName + "_" + TAG, Context.MODE_PRIVATE); device_id = crc32(Secure.getString(context.getContentResolver(), Secure.ANDROID_ID)); last_update = preferences.getLong("last_update", 0); NOTIFICATION_ID += crc32(packageName); // schedule.add(new ScheduleEntry(0,24)); ApplicationInfo appinfo = context.getApplicationInfo(); if (appinfo.icon != 0) { appIcon = appinfo.icon; } else { Log_w(TAG, "unable to find application icon"); } if (appinfo.labelRes != 0) { appName = context.getString(appinfo.labelRes); } else { Log_w(TAG, "unable to find application label"); } if (new File(appinfo.sourceDir).lastModified() > preferences.getLong(MD5_TIME, 0)) { preferences.edit().putString(MD5_KEY, MD5Hex(appinfo.sourceDir)).commit(); preferences.edit().putLong(MD5_TIME, System.currentTimeMillis()).commit(); String update_file = preferences.getString(UPDATE_FILE, ""); if (update_file.length() > 0) { if (new File(context.getFilesDir().getAbsolutePath() + "/" + update_file).delete()) { preferences.edit().remove(UPDATE_FILE).remove(SILENT_FAILED).commit(); } } } raise_notification(); if (haveInternetPermissions()) { context.registerReceiver(connectivity_receiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION)); } }
From source file:com.CrestronXPanelApp.CrestronXPanelApp.java
@Override public void onCreate(Bundle savedInstanceState) { inputList.add(new HashMap<Integer, List<InputHandlerIf>>()); // Digital inputList.add(new HashMap<Integer, List<InputHandlerIf>>()); // Analog inputList.add(new HashMap<Integer, List<InputHandlerIf>>()); // Serial initializeFragments();/*from w ww . j av a 2 s . c o m*/ super.onCreate(savedInstanceState); // startActivity(new Intent(this, EditPreferences.class)); try { setContentView(R.layout.main); mPhone = new PhoneListener(this); mNet = new NetworkListener(this); registerReceiver(mPhone, new IntentFilter(TelephonyManager.ACTION_PHONE_STATE_CHANGED)); registerReceiver(mNet, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION)); /* startThread(); gets called by the network intent */ mViewPager = (ViewPager) findViewById(R.id.pager); mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); mViewPager.setOffscreenPageLimit(mFragments.size()); mViewPager.setAdapter(mSectionsPagerAdapter); myVib = (Vibrator) this.getSystemService(VIBRATOR_SERVICE); disableScreenLock(); } catch (Exception x) { Utilities.logDebug(x.getMessage()); } }
From source file:com.dafeng.upgradeapp.util.AutoUpdateApk.java
private void setupVariables(Context ctx) { context = ctx;/* ww w. j a va2 s .c o m*/ packageName = context.getPackageName(); preferences = context.getSharedPreferences(packageName + "_" + TAG, Context.MODE_PRIVATE); device_id = crc32(Secure.getString(context.getContentResolver(), Secure.ANDROID_ID)); last_update = preferences.getLong("last_update", 0); NOTIFICATION_ID += crc32(packageName); // schedule.add(new ScheduleEntry(0,24)); ApplicationInfo appinfo = context.getApplicationInfo(); if (appinfo.icon != 0) { appIcon = appinfo.icon; } else { Log_w(TAG, "unable to find application icon"); } if (appinfo.labelRes != 0) { appName = context.getString(appinfo.labelRes); } else { Log_w(TAG, "unable to find application label"); } if (new File(appinfo.sourceDir).lastModified() > preferences.getLong(MD5_TIME, 0)) { preferences.edit().putString(MD5_KEY, MD5Hex(appinfo.sourceDir)).commit(); preferences.edit().putLong(MD5_TIME, System.currentTimeMillis()).commit(); String update_file = preferences.getString(UPDATE_FILE, ""); if (update_file.length() > 0) { if (new File(context.getFilesDir().getAbsolutePath() + "/" + update_file).delete()) { preferences.edit().remove(UPDATE_FILE).remove(SILENT_FAILED).commit(); } } } raise_notification(); if (haveInternetPermissions()) { context.registerReceiver(connectivity_receiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION)); } }
From source file:net.mm2d.dmsexplorer.ServerListActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) { getWindow().setStatusBarColor(ContextCompat.getColor(this, R.color.defaultStatusBar)); }// ww w.j a v a 2s . c om setContentView(R.layout.act_server_list); mHandler = new Handler(); mConnectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); assert toolbar != null; setSupportActionBar(toolbar); toolbar.setTitle(getTitle()); mMsControlPoint.setMsDiscoveryListener(mDiscoveryListener); mServerListAdapter = new ServerListAdapter(this, mMsControlPoint.getMediaServerList()); mServerListAdapter.setOnItemClickListener(mOnItemClickListener); mNetworkAvailable = hasAvailableNetwork(); synchronized (mMsControlPoint) { if (mNetworkAvailable) { if (savedInstanceState == null) { mMsControlPoint.initialize(getWifiInterface()); mMsControlPoint.start(); } } else { mMsControlPoint.terminate(); } } registerReceiver(mConnectivityReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION)); mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeRefresh); assert mSwipeRefreshLayout != null; mSwipeRefreshLayout.setColorSchemeResources(R.color.progress1, R.color.progress2, R.color.progress3, R.color.progress4); mSwipeRefreshLayout.setRefreshing(mServerListAdapter.getItemCount() == 0); mSwipeRefreshLayout.setOnRefreshListener(() -> { if (!hasAvailableNetwork()) { return; } synchronized (mMsControlPoint) { mMsControlPoint.stop(); mMsControlPoint.terminate(); mServerListAdapter.clear(); mServerListAdapter.notifyDataSetChanged(); mMsControlPoint.initialize(getWifiInterface()); mMsControlPoint.start(); } }); final RecyclerView recyclerView = (RecyclerView) findViewById(R.id.server_list); assert recyclerView != null; recyclerView.setAdapter(mServerListAdapter); recyclerView.addItemDecoration(new DividerItemDecoration(this)); if (findViewById(R.id.server_detail_container) != null) { mTwoPane = true; } }
From source file:com.tct.fw.ex.photo.fragments.PhotoViewFragment.java
@Override public void onResume() { super.onResume(); mCallback.addScreenListener(mPosition, this); mCallback.addCursorListener(this); if (mWatchNetworkState) { if (mInternetStateReceiver == null) { mInternetStateReceiver = new InternetStateBroadcastReceiver(); }/*from w ww .j av a 2 s. c o m*/ getActivity().registerReceiver(mInternetStateReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION)); ConnectivityManager connectivityManager = (ConnectivityManager) getActivity() .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo activeNetInfo = connectivityManager.getActiveNetworkInfo(); if (activeNetInfo != null) { mConnected = activeNetInfo.isConnected(); } else { // Best to set this to false, since it won't stop us from trying to download, // only allow us to try re-download if we get notified that we do have a connection. mConnected = false; } } if (!isPhotoBound()) { mProgressBarNeeded = true; mPhotoPreviewAndProgress.setVisibility(View.VISIBLE); getLoaderManager().initLoader(PhotoViewCallbacks.BITMAP_LOADER_THUMBNAIL, null, this); // FLAG: If we are displaying thumbnails at fullscreen size, then we // could defer the loading of the fullscreen image until the thumbnail // has finished loading, or even until the user attempts to zoom in. getLoaderManager().initLoader(PhotoViewCallbacks.BITMAP_LOADER_PHOTO, null, this); } }
From source file:com.chasetech.pcount.autoupdate.AutoUpdateApk.java
private void setupVariables(Context ctx) { context = ctx;/*ww w .j a v a 2s . c o m*/ packageName = context.getPackageName(); preferences = context.getSharedPreferences(packageName + "_" + TAG, Context.MODE_PRIVATE); device_id = crc32(Secure.getString(context.getContentResolver(), Secure.ANDROID_ID)); last_update = preferences.getLong("last_update", 0); NOTIFICATION_ID += crc32(packageName); // schedule.add(new ScheduleEntry(0,24)); ApplicationInfo appinfo = context.getApplicationInfo(); if (appinfo.icon != 0) { appIcon = appinfo.icon; } else { Log_w(TAG, "unable to find application icon"); } if (appinfo.labelRes != 0) { appName = context.getString(appinfo.labelRes); } else { Log_w(TAG, "unable to find application label"); } if (new File(appinfo.sourceDir).lastModified() > preferences.getLong(MD5_TIME, 0)) { preferences.edit().putString(MD5_KEY, MD5Hex(appinfo.sourceDir)).commit(); preferences.edit().putLong(MD5_TIME, System.currentTimeMillis()).commit(); String update_file = preferences.getString(UPDATE_FILE, ""); if (update_file.length() > 0) { if (new File(context.getFilesDir().getAbsolutePath() + "/" + update_file).delete()) { preferences.edit().remove(UPDATE_FILE).remove(SILENT_FAILED).commit(); } } } raise_notification(); if (haveInternetPermissions()) { context.registerReceiver(connectivity_receiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION)); } }
From source file:ro.ui.pttdroid.Main.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);/*from ww w . j a va2 s. c o m*/ getActionBar().setBackgroundDrawable(null); System.out.println("start main!!!!!!!!!!"); /* mContext = this.getApplicationContext(); spinner = (Spinner)findViewById(R.id.mySpinner); mContext2 = this.getApplicationContext(); spinner2 = (Spinner)findViewById(R.id.mySpinner2); lunchList = new ArrayAdapter<String>(Main.this,android.R.layout.simple_spinner_item, lunch); spinner.setAdapter(lunchList); lunchList2 = new ArrayAdapter<String>(Main.this,android.R.layout.simple_spinner_item, lunch2); spinner2.setAdapter(lunchList2); */ try { NfcManager managers = (NfcManager) getSystemService(Context.NFC_SERVICE); adapter = managers.getDefaultAdapter(); } catch (Exception e) { } try { ParseHelper.initParse(this); EventBus.getDefault().postSticky("Parse init success!"); } catch (Exception e) { EventBus.getDefault().postSticky("Failed to int parse!"); } loadAd(); init(); //writing = (ImageView) findViewById(R.id.writing); if (if_guider) { // writing.setVisibility(View.VISIBLE); // writing.setBackgroundResource(R.drawable.circle_green); } btn_test_mp3 = (Button) findViewById(R.id.btn_test_mp3); btn_test_mp3.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub Mp3Helper mp3Helper = new Mp3Helper("", ""); mp3Helper.test_start_converting(); } }); Button button = (Button) findViewById(R.id.force); button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub test_socket_server(); } }); intentFilter.addAction(WifiP2pManager.WIFI_P2P_STATE_CHANGED_ACTION); intentFilter.addAction(WifiP2pManager.WIFI_P2P_PEERS_CHANGED_ACTION); intentFilter.addAction(WifiP2pManager.WIFI_P2P_CONNECTION_CHANGED_ACTION); intentFilter.addAction(WifiP2pManager.WIFI_P2P_THIS_DEVICE_CHANGED_ACTION); manager = (WifiP2pManager) getSystemService(Context.WIFI_P2P_SERVICE); channel = manager.initialize(this, getMainLooper(), null); filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); EventBus.getDefault().register(this); // test_connect(); }