@Override public void handleButtonPress(int index) { if (index == 0) { WifiParsedResult wifiResult = (WifiParsedResult) getResult(); WifiManager wifiManager = (WifiManager) getActivity().getSystemService(Context.WIFI_SERVICE); if (wifiManager == null) { Log.w(TAG, "No WifiManager available from device"); return; } final Activity activity = getActivity(); activity.runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(activity.getApplicationContext(), R.string.wifi_changing_network, Toast.LENGTH_SHORT).show(); } }); new WifiConfigManager(wifiManager).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, wifiResult); parent.restartPreviewAfterDelay(0L); } }
@Override public void handleButtonPress(int index) { if (index == 0) { WifiParsedResult wifiResult = (WifiParsedResult) getResult(); WifiManager wifiManager = (WifiManager) getActivity().getSystemService(Context.WIFI_SERVICE); final Activity activity = getActivity(); activity.runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(activity.getApplicationContext(), R.string.wifi_changing_network, Toast.LENGTH_SHORT).show(); } }); taskExec.execute(new WifiConfigManager(wifiManager), wifiResult); parent.restartPreviewAfterDelay(0L); } }
@TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override public void handleButtonPress(int index) { if (index == 0) { WifiParsedResult wifiResult = (WifiParsedResult) getResult(); WifiManager wifiManager = (WifiManager) getActivity().getSystemService(Context.WIFI_SERVICE); if (wifiManager == null) { Log.w(TAG, "No WifiManager available from device"); return; } final Activity activity = getActivity(); activity.runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(activity.getApplicationContext(), R.string.wifi_changing_network, Toast.LENGTH_SHORT) .show(); } }); // new WifiConfigManager(wifiManager).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, wifiResult); /** * @author MichaelX(xiong_it)modified.{@link https://github.com/xiong-it} * * {@link http://stackoverflow.com/questions/12227682/android-2-3-3-asynctask-call-throws-nosuchfielderror} * THREAD_POOL_EXECUTOR were added in API Level 11 */ AsyncTask task = new WifiConfigManager(wifiManager); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, wifiResult); } else { task.execute(wifiResult); } parent.restartPreviewAfterDelay(0L); } }
@Override public void handleButtonPress(int index) { if (index == 0) { WifiParsedResult wifiResult = (WifiParsedResult) getResult(); WifiManager wifiManager = (WifiManager) getActivity().getSystemService(Context.WIFI_SERVICE); Toast.makeText(getActivity(), fakeR.getId("string", "wifi_changing_network"), Toast.LENGTH_LONG).show(); taskExec.execute(new WifiConfigManager(wifiManager), wifiResult); parent.restartPreviewAfterDelay(0L); } }
@Override public void handleButtonPress(int index) { if (index == 0) { WifiParsedResult wifiResult = (WifiParsedResult) getResult(); WifiManager wifiManager = (WifiManager) getActivity().getSystemService(Context.WIFI_SERVICE); Toast.makeText(getActivity(), R.string.wifi_changing_network, Toast.LENGTH_LONG).show(); taskExec.execute(new WifiConfigManager(wifiManager), wifiResult); parent.restartPreviewAfterDelay(0L); } }