Avoid Toast that won't go away by posting on UI thread

git-svn-id: https://zxing.googlecode.com/svn/trunk@2524 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen 2012-11-20 07:45:31 +00:00
parent 42dcca3ccf
commit 4f93e88db1

View file

@ -16,6 +16,7 @@
package com.google.zxing.client.android.result; package com.google.zxing.client.android.result;
import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.net.wifi.WifiManager; import android.net.wifi.WifiManager;
import android.widget.Toast; import android.widget.Toast;
@ -61,7 +62,13 @@ public final class WifiResultHandler extends ResultHandler {
if (index == 0) { if (index == 0) {
WifiParsedResult wifiResult = (WifiParsedResult) getResult(); WifiParsedResult wifiResult = (WifiParsedResult) getResult();
WifiManager wifiManager = (WifiManager) getActivity().getSystemService(Context.WIFI_SERVICE); WifiManager wifiManager = (WifiManager) getActivity().getSystemService(Context.WIFI_SERVICE);
Toast.makeText(getActivity(), R.string.wifi_changing_network, Toast.LENGTH_LONG).show(); 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); taskExec.execute(new WifiConfigManager(wifiManager), wifiResult);
parent.restartPreviewAfterDelay(0L); parent.restartPreviewAfterDelay(0L);
} }