List of usage examples for android.support.v4.content LocalBroadcastManager getInstance
public static LocalBroadcastManager getInstance(Context context)
From source file:com.android.managedprovisioning.DeviceOwnerProvisioningService.java
private void onProvisioningSuccess() { // Copying an account needs to happen late in the provisioning process to allow the current // user to be started, but before we tell the MDM that provisioning succeeded. maybeCopyAccount();/*from w ww . j a v a2 s .c o m*/ if (DEBUG) ProvisionLogger.logd("Reporting success."); mDone = true; // Set DPM userProvisioningState appropriately and persists mParams for use during // FinalizationActivity if necessary. mUtils.markUserProvisioningStateInitiallyDone(this, mParams); Intent successIntent = new Intent(ACTION_PROVISIONING_SUCCESS); successIntent.setClass(this, DeviceOwnerProvisioningActivity.ServiceMessageReceiver.class); LocalBroadcastManager.getInstance(this).sendBroadcast(successIntent); // Wait for stopService() call from the activity. }
From source file:cc.echonet.coolmicapp.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.home);/*w ww . j av a 2 s. c om*/ timerValue = (TextView) findViewById(R.id.timerValue); BroadcastReceiver mPowerKeyReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { String strAction = intent.getAction(); if (strAction.equals(Intent.ACTION_SCREEN_OFF) || strAction.equals(Intent.ACTION_SCREEN_ON) || strAction.equals(Intent.ACTION_USER_PRESENT)) { if (isThreadOn) { RedFlashLight(); } } } }; final IntentFilter theFilter = new IntentFilter(); /** System Defined Broadcast */ theFilter.addAction(Intent.ACTION_SCREEN_ON); theFilter.addAction(Intent.ACTION_SCREEN_OFF); theFilter.addAction(Intent.ACTION_USER_PRESENT); getApplicationContext().registerReceiver(mPowerKeyReceiver, theFilter); imageView1 = (ImageView) findViewById(R.id.imageView1); Log.v("onCreate", (imageView1 == null ? "iv null" : "iv ok")); android.view.ViewGroup.LayoutParams layoutParams = imageView1.getLayoutParams(); if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { layoutParams.height = 400; } else { layoutParams.height = 180; } imageView1.setLayoutParams(layoutParams); myClipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); animation.setDuration(500); // duration - half a second animation.setInterpolator(new LinearInterpolator()); // do not alter animation rate animation.setRepeatCount(Animation.INFINITE); // Repeat animation infinitely animation.setRepeatMode(Animation.REVERSE); start_button = (Button) findViewById(R.id.start_recording_button); stop_button = (Button) findViewById(R.id.stop_recording_button); buttonColor = start_button.getBackground(); logArea = (TextView) findViewById(R.id.log_area); logArea.setMovementMethod(new ScrollingMovementMethod()); coolmic = new CoolMic(this, "default"); if (Wrapper.getState() == Wrapper.WrapperInitializationStatus.WRAPPER_UNINITIALIZED) { if (Wrapper.init() == Wrapper.WrapperInitializationStatus.WRAPPER_INITIALIZATION_ERROR) { Log.d("WrapperInit", Wrapper.getInitException().toString()); Toast.makeText(getApplicationContext(), "Could not initialize native components :( Blocking controls!", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(getApplicationContext(), "Native components initialized!", Toast.LENGTH_SHORT) .show(); } } else if (Wrapper.init() == Wrapper.WrapperInitializationStatus.WRAPPER_INITIALIZATION_ERROR) { Toast.makeText(getApplicationContext(), "Previous problem detected with native components :( Blocking controls!", Toast.LENGTH_SHORT) .show(); } else if (Wrapper.init() != Wrapper.WrapperInitializationStatus.WRAPPER_INTITIALIZED) { Toast.makeText(getApplicationContext(), "Native components in unknown state!", Toast.LENGTH_SHORT) .show(); } txtListeners = (TextView) findViewById(R.id.txtListeners); IntentFilter mStatusIntentFilter = new IntentFilter(Constants.BROADCAST_STREAM_STATS_SERVICE); LocalBroadcastManager.getInstance(this).registerReceiver(mStreamStatsReceiver, mStatusIntentFilter); }
From source file:com.air.mobilebrowser.BrowserActivity.java
@Override public void onDestroy() { super.onDestroy(); LocalBroadcastManager.getInstance(super.getApplicationContext()).unregisterReceiver(mSBReceiver); mDeviceStatus.unregisterReceivers(this); ttsPlayer.destroy();// w w w .jav a 2 s . c o m mWebView.loadUrl("about:blank"); clearHome(); }
From source file:ca.zadrox.dota2esportticker.ui.MatchDetailActivity.java
@Override public void onResume() { super.onResume(); if (mTimeHintUpdaterRunnable != null) { mHandler.postDelayed(mTimeHintUpdaterRunnable, TIME_HINT_UPDATE_INTERVAL); }/*ww w . j a v a2 s. c om*/ LocalBroadcastManager.getInstance(this).registerReceiver(mSteamAPIKeyIncorrectReceiver, new IntentFilter(SteamAuth.STEAM_API_KEY_INCORRECT)); }
From source file:com.alibaba.weex.IndexActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_index); setContainer((ViewGroup) findViewById(R.id.index_container)); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);/*from ww w. j av a2s .c o m*/ getWindow().setFormat(PixelFormat.TRANSLUCENT); mProgressBar = (ProgressBar) findViewById(R.id.index_progressBar); mTipView = (TextView) findViewById(R.id.index_tip); mProgressBar.setVisibility(View.VISIBLE); mTipView.setVisibility(View.VISIBLE); if (!WXSoInstallMgrSdk.isCPUSupport()) { mProgressBar.setVisibility(View.INVISIBLE); mTipView.setText(R.string.cpu_not_support_tip); return; } if (TextUtils.equals(sCurrentIp, DEFAULT_IP)) { renderPage(WXFileUtils.loadAsset("index.js", this), getIndexUrl()); } else { renderPageByURL(getIndexUrl()); } mReloadReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { createWeexInstance(); if (TextUtils.equals(sCurrentIp, DEFAULT_IP)) { renderPage(WXFileUtils.loadAsset("index.js", getApplicationContext()), getIndexUrl()); } else { renderPageByURL(getIndexUrl()); } mProgressBar.setVisibility(View.VISIBLE); } }; LocalBroadcastManager.getInstance(this).registerReceiver(mReloadReceiver, new IntentFilter(WXSDKEngine.JS_FRAMEWORK_RELOAD)); }
From source file:com.alibaba.weex.extend.module.GeolocationModule.java
private void requestPermission(String successCallback, String errorCallback, String params, int requestCurPermissionCode) { ActivityCompat.requestPermissions((Activity) mWXSDKInstance.getContext(), new String[] { Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION }, requestCurPermissionCode);/*from w w w . jav a 2 s.c o m*/ LocalBroadcastManager.getInstance(mWXSDKInstance.getContext()) .registerReceiver(new PerReceiver(mWXSDKInstance.getInstanceId(), mILocatable, successCallback, errorCallback, params), new IntentFilter("actionRequestPermissionsResult")); }
From source file:biz.wiz.android.wallet.WalletApplication.java
public void resetBlockchain() { internalResetBlockchain();//from w ww . j ava 2s .c o m final Intent broadcast = new Intent(ACTION_WALLET_CHANGED); broadcast.setPackage(getPackageName()); LocalBroadcastManager.getInstance(this).sendBroadcast(broadcast); }
From source file:cc.softwarefactory.lokki.android.utilities.ServerApi.java
public static void removePlace(final Context context, final String placeId) throws JSONException { Log.e(TAG, "removePlace"); AQuery aq = new AQuery(context); String userId = PreferenceUtils.getString(context, PreferenceUtils.KEY_USER_ID); String authorizationToken = PreferenceUtils.getString(context, PreferenceUtils.KEY_AUTH_TOKEN); String url = ApiUrl + "user/" + userId + "/place/" + placeId; AjaxCallback<JSONObject> cb = new AjaxCallback<JSONObject>() { @Override//w w w . j a va 2 s . c o m public void callback(String url, JSONObject object, AjaxStatus status) { Log.e(TAG, "removePlace result code: " + status.getCode()); Log.e(TAG, "removePlace result message: " + status.getMessage()); Log.e(TAG, "removePlace ERROR: " + status.getError()); if (status.getError() == null) { Log.e(TAG, "No error, continuing deletion."); MainApplication.places.remove(placeId); Toast.makeText(context, context.getResources().getString(R.string.place_removed), Toast.LENGTH_SHORT).show(); Intent intent = new Intent("PLACES-UPDATE"); LocalBroadcastManager.getInstance(context).sendBroadcast(intent); } } }; cb.header("authorizationtoken", authorizationToken); aq.delete(url, JSONObject.class, cb); }
From source file:com.anykey.balala.activity.MainActivity.java
@Override protected void onPause() { LocalBroadcastManager.getInstance(MainActivity.this).unregisterReceiver(receiver); super.onPause(); }
From source file:ca.zadrox.dota2esportticker.ui.MatchDetailActivity.java
@Override public void onPause() { super.onPause(); if (mTimeHintUpdaterRunnable != null) { mHandler.removeCallbacks(mTimeHintUpdaterRunnable); }//w ww. j av a 2 s . c om LocalBroadcastManager.getInstance(this).unregisterReceiver(mSteamAPIKeyIncorrectReceiver); }