List of usage examples for android.os Handler Handler
public Handler()
From source file:com.shonshampain.streamrecorder.util.StreamProxy.java
public void start() { Logger.logEvent("StreamProxy:start()"); isRunning = true;/*www . j a va2 s .c o m*/ init(); EventBus.getDefault().register(this); thread = new Thread(this); thread.start(); Handler handler = new Handler(); Runnable postAcceptingConnectionsRunnable = new Runnable() { @Override public void run() { EventBus.getDefault().post(new ProxyAcceptingConnectionsEvent()); Logger.logEvent("Proxy is accepting connections"); } }; // This is a bit of a hack. // We want to post the event after socket.accept, // but after socket.accept, we're in a wait state // This is good enough. handler.postDelayed(postAcceptingConnectionsRunnable, 1000); }
From source file:com.funambol.android.controller.AndroidRegisterScreenController.java
public AndroidRegisterScreenController(Controller controller, Customization customization, Configuration configuration, Localization localization, AppSyncSourceManager appSyncSourceManager, AccountScreen registerScreen) {/*www.j a va 2 s . c o m*/ super(controller, customization, configuration, localization, appSyncSourceManager, registerScreen); displayManager = (AndroidDisplayManager) controller.getDisplayManager(); networkStatus = new NetworkStatus((Activity) registerScreen.getUiScreen()); engine.setNetworkStatus(networkStatus); spinnerTriggerUIThread = new SpinnerTriggerUIThread(); messageUIThread = new MessageUIThread(); screen = (AndroidRegisterActivity) registerScreen; this.configuration = configuration; this.customization = customization; this.localization = localization; this.appSyncSourceManager = appSyncSourceManager; gc = AndroidController.getInstance(); homeScreenController = (AndroidHomeScreenController) gc.getHomeScreenController(); handler = new Handler() { public void handleMessage(Message m) { String result = m.getData().getString("RESPONSE").trim(); spinnerTriggerUIThread.setValue(false); screen.runOnUiThread(spinnerTriggerUIThread); String r = result.trim(); int iRes = Integer.parseInt(r); screen.notifyClientValidateInfo(iRes); if (RetRegOK == iRes) { // Okay, save the configuration Configuration configuration = AndroidRegisterScreenController.this.configuration; configuration.setUsername(screen.getUsername()); configuration.setPassword(screen.getPassword()); Customization customization = AndroidRegisterScreenController.this.customization; if (configuration.save() != configuration.CONF_OK) { Toast.makeText(screen, AndroidRegisterScreenController.this.localization.getLanguage("reg_ret_ok"), 4000) .show(); } else { // saveAccount(); //shawnqiu, 20110123. homeScreenController.updateUserInfo(); // //Toast.makeText(screen, AndroidRegisterScreenController.this.localization.getLanguage("signup_succeeded"), 3000).show(); //showSignupSucceededMessage(AndroidRegisterScreenController.this.localization.getLanguage("signup_succeeded")); //runContactsImport(); } } else { screen.enableRegister(); //TODO } } }; }
From source file:com.google.appinventor.components.runtime.Voting.java
public Voting(ComponentContainer container) { super(container.$form()); serviceURL = "http://androvote.appspot.com"; userId = "";/*from w w w. j a v a 2 s. c o m*/ isPolling = false; idRequested = false; ballotQuestion = ""; ballotOptions = new ArrayList<String>(); userChoice = ""; androidUIHandler = new Handler(); theContainer = container; activityContext = container.$context(); // We set the initial value of serviceURL to be the // demo Web service serviceURL = "http://androvote.appspot.com"; }
From source file:net.networksaremadeofstring.rhybudd.ViewZenossDeviceFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); BugSenseHandler.initAndStartSession(getActivity(), "44a76a8c"); loadAverageHandler = new Handler() { public void handleMessage(Message msg) { try { loadAverageGraphView.setImageDrawable(loadAverageGraph); loadAverageGraph = null; } catch (Exception e) { BugSenseHandler.sendExceptionMessage("ViewZenossDeviceFragment", "loadAverageHandler", e); }// w w w . j a va 2s. c o m } }; errorHandler = new Handler() { public void handleMessage(Message msg) { try { CPUGraphView.setVisibility(View.GONE); MemoryGraphView.setVisibility(View.GONE); loadAverageGraphView.setVisibility(View.GONE); hsv.setVisibility(View.GONE); } catch (Exception e) { BugSenseHandler.sendExceptionMessage("ViewZenossDeviceFragment", "errorHandler", e); } } }; CPUGraphHandler = new Handler() { public void handleMessage(Message msg) { try { CPUGraphView.setImageDrawable(CPUGraph); CPUGraph = null; } catch (Exception e) { BugSenseHandler.sendExceptionMessage("ViewZenossDeviceFragment", "CPUGraphHandler", e); } } }; MemoryGraphHandler = new Handler() { public void handleMessage(Message msg) { try { MemoryGraphView.setImageDrawable(MemoryGraph); MemoryGraph = null; } catch (Exception e) { BugSenseHandler.sendExceptionMessage("ViewZenossDeviceFragment", "MemoryGraphHandler", e); } } }; }
From source file:com.raceyourself.android.samsung.ProviderService.java
/** * Called when the service is started, even if already running *///from www. ja va 2s . c o m @Override public int onStartCommand(Intent i, int j, int k) { ORMDroidApplication.initialize(this); // init the database // check the user has done everything they need to // separate thread to allow onCreate() to complete and SAP to // deploy the wgt to gear. // Don't trigger if init is already in progress, or we're already connected to gear if (!initialisingInProgress && mConnectionsMap.isEmpty()) { new Handler().post(new Runnable() { public void run() { runUserInit(); } }); } // make sure we have a record for the user Helper.getUser(); // Initialize helper singleton Helper.getInstance(this); int result = super.onStartCommand(i, j, k); Log.v(TAG, "service created"); return result; }
From source file:com.silentcircle.silenttext.activity.AccountCreationActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.fragment);/*from www . j av a 2 s .c o m*/ findViewById(R.id.error).setVisibility(View.GONE); handler = new Handler(); hideError = new ViewAnimator(this, R.id.error, R.anim.slide_up); Fragment fragment = getFragmentManager().findFragmentById(R.id.content); if (fragment == null) { Bundle bundle = toBundle(getIntent()); CharSequence licenseCode = bundle.getCharSequence(AccountCreationFragment.EXTRA_LICENSE_CODE); if (StringUtils.isEmpty(licenseCode)) { // check for application level license code LicenseCodeProvider provider = new ApplicationLicenseCodeProvider(); licenseCode = provider.provideLicenseCode(this); if (StringUtils.isEmpty(licenseCode)) { // check for auto-generated partner license codes provider = new EligibleLicenseCodeProvider(DeviceUtils.getPartnerEligibility(this), new DeviceIDLicenseCodeProvider()); licenseCode = provider.provideLicenseCode(this); } bundle.putCharSequence(AccountCreationFragment.EXTRA_LICENSE_CODE, licenseCode); } fragment = AccountCreationWelcomeFragment.create(bundle); getFragmentManager().beginTransaction().add(R.id.content, fragment).commit(); } if (fragment instanceof HasFlow) { ((HasFlow) fragment).setFlowListener(this); } getFragmentManager().addOnBackStackChangedListener(new OnBackStackChangedListener() { @Override public void onBackStackChanged() { Fragment f = getFragmentManager().findFragmentById(R.id.content); if (f instanceof HasFlow) { ((HasFlow) f).setFlowListener(AccountCreationActivity.this); } } }); }
From source file:com.rightscale.app.dashboard.ShowServerMonitoring.java
public void loadContent() { //NOTE: we don't call super since most server info isn't needed _helper.onLoadContent();// ww w . j a v a 2s . c o m ContentTransfer.load(this, this, new Handler(), MONITORS); }
From source file:com.scooter1556.sms.androidtv.fragment.VideoPlayerFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); restService = RESTService.getInstance(); player = new SMSVideoPlayer(); surfaceHolder = ((VideoPlayerActivity) getActivity()).getSurfaceHolder(); surfaceHolder.addCallback(this); handler = new Handler(); seekHandler = new Handler(); // Retrieve media element to play mediaElement = (MediaElement) getActivity().getIntent().getSerializableExtra("MediaElement"); setBackgroundType(BACKGROUND_TYPE);//from w w w .ja v a 2 s. c o m setFadingEnabled(false); setupRows(); }
From source file:ch.ethz.twimight.net.opportunistic.ScanningService.java
@Override public void onCreate() { // TODO Auto-generated method stub super.onCreate(); handler = new Handler(); // set up Bluetooth bluetoothHelper = new BluetoothComms(this, mHandler); bluetoothHelper.start();//from ww w . j av a2 s .co m dbHelper = new MacsDBHelper(getApplicationContext()); dbHelper.open(); // sdCard helper sdCardHelper = new SDCardHelper(); // htmldb helper htmlDbHelper = new HtmlPagesDbHelper(getApplicationContext()); htmlDbHelper.open(); mBtAdapter = BluetoothAdapter.getDefaultAdapter(); }
From source file:com.facebook.android.friendsmash.GameFragment.java
@SuppressWarnings("unused") @Override/*from w w w.j a v a 2 s . c o m*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setRetainInstance(true); // Instantiate the handlers timerHandler = new Handler(); uiHandler = new Handler(); // Get the friend to smash bitmap and name if (FriendSmashApplication.IS_SOCIAL) { // User is logged into FB, so choose a random FB friend to smash friendToSmashIndex = getRandomFriendIndex(); } else { // User is not logged into FB, so choose a random celebrity to smash celebToSmashIndex = getRandomCelebIndex(); } }