本文整理匯總了Java中android.support.v4.content.LocalBroadcastManager.sendBroadcast方法的典型用法代碼示例。如果您正苦於以下問題:Java LocalBroadcastManager.sendBroadcast方法的具體用法?Java LocalBroadcastManager.sendBroadcast怎麽用?Java LocalBroadcastManager.sendBroadcast使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.v4.content.LocalBroadcastManager
的用法示例。
在下文中一共展示了LocalBroadcastManager.sendBroadcast方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: run
import android.support.v4.content.LocalBroadcastManager; //導入方法依賴的package包/類
@Override
public void run() {
try {
sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
LocalBroadcastManager _manager = LocalBroadcastManager.getInstance(Global.get_applicationContext());
SDFile _file;
for (int _temp_i = 0; _temp_i < _files.size(); _temp_i++) {
_file = _files.valueAt(_temp_i);
_file.delete(false);
if (FileManager.get_state() == FileManager.STATE_DELETE_EXECUTING) {
Intent _delete = new Intent(ACTION_DELETE);
_delete.putExtra("index", _files.keyAt(_temp_i));
_manager.sendBroadcast(_delete);
} else
break;
}
FileManager.finishDelete();
Intent _finish = new Intent(ACTION_FINISH);
_manager.sendBroadcast(_finish);
}
示例2: onHandleIntent
import android.support.v4.content.LocalBroadcastManager; //導入方法依賴的package包/類
@Override
protected void onHandleIntent(Intent intent) {
RequestPackage requestPackage =
intent.getParcelableExtra(REQUEST_PACKAGE);
Intent messageIntent = new Intent(NUTRITION_SERVICE_NAME);
LocalBroadcastManager manager =
LocalBroadcastManager.getInstance(getApplicationContext());
String response;
try {
response = HttpHelper.makeRequest(requestPackage, null);
Gson gson = new Gson();
NutritionixData nutritionixData = gson.fromJson(response, NutritionixData.class);
messageIntent.putExtra(NUTRITION_SERVICE_PAYLOAD, nutritionixData);
} catch (Exception e) {
e.printStackTrace();
messageIntent.putExtra(NUTRITION_SERVICE_ERROR, e.getMessage());
}
manager.sendBroadcast(messageIntent);
}
示例3: onTokenRefresh
import android.support.v4.content.LocalBroadcastManager; //導入方法依賴的package包/類
@Override
public void onTokenRefresh() {
String refreshedToken = FirebaseInstanceId.getInstance().getToken();
final Intent intent = new Intent("tokenReceiver");
// You can also include some extra data.
final LocalBroadcastManager broadcastManager = LocalBroadcastManager.getInstance(this);
intent.putExtra("token",refreshedToken);
broadcastManager.sendBroadcast(intent);
// Get updated InstanceID token.
Log.d("Token Is : ", refreshedToken);
// TODO: Implement this method to send any registration to your app's servers.
// sendRegistrationToServer(refreshedToken);
}
示例4: onCancel
import android.support.v4.content.LocalBroadcastManager; //導入方法依賴的package包/類
@Override
public void onCancel(final DialogInterface dialog) {
final LocalBroadcastManager manager = LocalBroadcastManager.getInstance(getActivity());
final Intent pauseAction = new Intent(DfuService.BROADCAST_ACTION);
pauseAction.putExtra(DfuService.EXTRA_ACTION, DfuService.ACTION_RESUME);
manager.sendBroadcast(pauseAction);
}
示例5: showUploadCancelDialog
import android.support.v4.content.LocalBroadcastManager; //導入方法依賴的package包/類
private void showUploadCancelDialog() {
final LocalBroadcastManager manager = LocalBroadcastManager.getInstance(this);
final Intent pauseAction = new Intent(DfuService.BROADCAST_ACTION);
pauseAction.putExtra(DfuService.EXTRA_ACTION, DfuService.ACTION_PAUSE);
manager.sendBroadcast(pauseAction);
final UploadCancelFragment fragment = UploadCancelFragment.getInstance();
fragment.show(getSupportFragmentManager(), TAG);
}
示例6: onDestroy
import android.support.v4.content.LocalBroadcastManager; //導入方法依賴的package包/類
@Override
protected void onDestroy() {
super.onDestroy();
Log.d("PopUpActivity", "onDestroy()");
LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance(this);
localBroadcastManager.sendBroadcast(new Intent(INTENT_ACTION_DESTROYED));
localBroadcastManager.unregisterReceiver(broadcastReceiver);
releaseViews();
}
示例7: sendReport
import android.support.v4.content.LocalBroadcastManager; //導入方法依賴的package包/類
private void sendReport(@Nullable Station correctStation) {
// build report
Map<String, Object> map = new HashMap<>();
if (incorrectStation == null) {
map.put("incorrectStation", "none");
} else {
map.put("incorrectStation", incorrectStation.getId());
}
if (correctStation == null) {
map.put("correctStation", "none");
} else {
map.put("correctStation", correctStation.getId());
}
map.put("wiFiScanResults", scanResults);
ObjectMapper mapper = new ObjectMapper();
try {
String jsonResult = mapper.writerWithDefaultPrettyPrinter()
.writeValueAsString(map);
Realm realm = Realm.getDefaultInstance();
realm.beginTransaction();
Feedback feedback = realm.createObject(Feedback.class, UUID.randomUUID().toString());
feedback.setSynced(false);
feedback.setTimestamp(new Date());
feedback.setType("s2ls-incorrect-detection");
feedback.setContents(jsonResult);
realm.copyToRealm(feedback);
realm.commitTransaction();
realm.close();
Intent intent = new Intent(ACTION_FEEDBACK_PROVIDED);
intent.putExtra(EXTRA_FEEDBACK_PROVIDED_DELAYED, !Connectivity.isConnected(context));
LocalBroadcastManager bm = LocalBroadcastManager.getInstance(context);
bm.sendBroadcast(intent);
} catch (JsonProcessingException e) {
e.printStackTrace();
}
}
示例8: markLineAsUp
import android.support.v4.content.LocalBroadcastManager; //導入方法依賴的package包/類
public void markLineAsUp(Line line) {
synchronized (lock) {
// ensure line statuses are loaded, otherwise our map will only contain this line
getLineStatus();
lineStatuses.put(line.getId(), new Status(line));
cacheLineStatus(lineStatuses);
}
Intent intent = new Intent(ACTION_LINE_STATUS_UPDATE_SUCCESS);
LocalBroadcastManager bm = LocalBroadcastManager.getInstance(context);
bm.sendBroadcast(intent);
}
示例9: onPostExecute
import android.support.v4.content.LocalBroadcastManager; //導入方法依賴的package包/類
protected void onPostExecute(Boolean result) {
Log.d("UpdateTopologyTask", result.toString());
currentUpdateTopologyTask = null;
Intent intent = new Intent(ACTION_UPDATE_TOPOLOGY_FINISHED);
intent.putExtra(EXTRA_UPDATE_TOPOLOGY_FINISHED, result);
LocalBroadcastManager bm = LocalBroadcastManager.getInstance(MainService.this);
bm.sendBroadcast(intent);
}
示例10: onCancelled
import android.support.v4.content.LocalBroadcastManager; //導入方法依賴的package包/類
@Override
protected void onCancelled() {
Log.d("UpdateTopologyTask", "onCancelled");
currentUpdateTopologyTask = null;
Intent intent = new Intent(ACTION_UPDATE_TOPOLOGY_CANCELLED);
LocalBroadcastManager bm = LocalBroadcastManager.getInstance(MainService.this);
bm.sendBroadcast(intent);
}
示例11: onStateChanged
import android.support.v4.content.LocalBroadcastManager; //導入方法依賴的package包/類
@Override
public void onStateChanged(final S2LS loc) {
Log.d("onStateChanged", "State changed");
stateTickHandler.removeCallbacksAndMessages(null);
if (loc.getState().getPreferredTickIntervalMillis() != 0) {
doTick(loc.getState());
}
SharedPreferences sharedPref = getSharedPreferences("settings", MODE_PRIVATE);
boolean locationEnabled = sharedPref.getBoolean("pref_location_enable", true);
if (loc.getState() instanceof InNetworkState) {
wfc.setScanInterval(TimeUnit.SECONDS.toMillis(10));
if (locationEnabled) {
wfc.startScanning();
}
if (loc.getCurrentTrip() != null) {
updateRouteNotification(loc);
}
} else if (loc.getState() instanceof NearNetworkState) {
wfc.setScanInterval(TimeUnit.MINUTES.toMillis(1));
if (locationEnabled)
wfc.startScanningIfWiFiEnabled();
checkStopForeground(loc);
} else if (loc.getState() instanceof OffNetworkState) {
// wfc.stopScanning(); // TODO only enable this when there are locators besides WiFi
wfc.setScanInterval(TimeUnit.MINUTES.toMillis(1));
if (locationEnabled)
wfc.startScanningIfWiFiEnabled();
checkStopForeground(loc);
}
Intent intent = new Intent(ACTION_S2LS_STATUS_CHANGED);
LocalBroadcastManager bm = LocalBroadcastManager.getInstance(MainService.this);
bm.sendBroadcast(intent);
}
示例12: onMessageReceived
import android.support.v4.content.LocalBroadcastManager; //導入方法依賴的package包/類
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
for (Map.Entry<String, String> entry : remoteMessage.getData().entrySet()) {
System.out.println("getData() Key: " + entry.getKey() + " value: " + entry.getValue());
if (entry.getKey().equalsIgnoreCase("message")) {
NetUtils.setUpSSL(getApplicationContext());
if (entry.getValue().equalsIgnoreCase("download")) {
Log.d(getClass().getName(), "Download received");
ActivityManager am = (ActivityManager)getSystemService(Context.ACTIVITY_SERVICE);
ComponentName cn = am.getRunningTasks(1).get(0).topActivity;
Log.d(getClass().getName(), "Current component: "+cn.getClassName());
if (cn.getClassName().equals(PersoActivity.class.getName())) {
Log.d(getClass().getName(), "Sending broadcast DOWNLOAD_LICENSE;");
LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance(getApplicationContext());
localBroadcastManager.sendBroadcast(new Intent("download_license"));
} else {
new Handler(Looper.getMainLooper()).post(
new Runnable() {
public void run() {
new WebAPI.DownloadLicenseDataTask(getApplicationContext()).execute();
}
}
);
}
} else if (entry.getValue().equalsIgnoreCase("revoke")) {
Log.d(getClass().getName(), "Revoke received");
Future<BooleanValue> shouldRevokeFuture = executor.submit(new WebAPI.ShouldRevokeTask());
try {
BooleanValue shouldRevoke = shouldRevokeFuture.get();
if (shouldRevoke != null && shouldRevoke.isValue()) {
SettingsFragment.deleteAllData(getApplicationContext());
}
} catch (InterruptedException | ExecutionException e) {
Log.e(getClass().getName(), e.getMessage(), e);
}
}
}
}
}
示例13: onPreExecute
import android.support.v4.content.LocalBroadcastManager; //導入方法依賴的package包/類
@Override
protected void onPreExecute() {
Intent intent = new Intent(ACTION_LINE_STATUS_UPDATE_STARTED);
LocalBroadcastManager bm = LocalBroadcastManager.getInstance(context);
bm.sendBroadcast(intent);
}
示例14: onProgressUpdate
import android.support.v4.content.LocalBroadcastManager; //導入方法依賴的package包/類
protected void onProgressUpdate(Integer... progress) {
Intent intent = new Intent(ACTION_UPDATE_TOPOLOGY_PROGRESS);
intent.putExtra(EXTRA_UPDATE_TOPOLOGY_PROGRESS, progress[0]);
LocalBroadcastManager bm = LocalBroadcastManager.getInstance(MainService.this);
bm.sendBroadcast(intent);
}
示例15: onChange
import android.support.v4.content.LocalBroadcastManager; //導入方法依賴的package包/類
@Override
public void onChange(RealmResults<Trip> element) {
Intent intent = new Intent(ACTION_TRIP_REALM_UPDATED);
LocalBroadcastManager bm = LocalBroadcastManager.getInstance(MainService.this);
bm.sendBroadcast(intent);
}