use of android.support.v4.content.LocalBroadcastManager in project Gadgetbridge by Freeyourgadget.
the class HPlusSupport method dispose.
@Override
public void dispose() {
LOG.debug("Dispose");
LocalBroadcastManager broadcastManager = LocalBroadcastManager.getInstance(getContext());
broadcastManager.unregisterReceiver(mReceiver);
close();
super.dispose();
}
use of android.support.v4.content.LocalBroadcastManager in project AndroidTraining by mixi-inc.
the class MainActivity method onStart.
@Override
protected void onStart() {
super.onStart();
// この Activity の Context の中での、Local な Broadcast を管理する為の LocalBroadcastManager オブジェクト
LocalBroadcastManager manager = LocalBroadcastManager.getInstance(this);
manager.registerReceiver(mReceiver, new IntentFilter(ACTION_HOGEHOGE));
}
use of android.support.v4.content.LocalBroadcastManager in project AndroidTraining by mixi-inc.
the class MainActivity method onStop.
@Override
protected void onStop() {
LocalBroadcastManager manager = LocalBroadcastManager.getInstance(this);
manager.unregisterReceiver(mReceiver);
super.onStop();
}
use of android.support.v4.content.LocalBroadcastManager in project chefly_android by chef-ly.
the class MyService method onHandleIntent.
//called automaticly when server starts, receives data as an argument
@Override
protected void onHandleIntent(Intent intent) {
RequestMethod requestPackage = intent.getParcelableExtra(REQUEST_PACKAGE);
String sender = intent.getStringExtra("Tag");
Log.d(TAG, "Sender -> " + sender);
Log.d(TAG, "Request Package Endpoint-> " + requestPackage.getEndpoint());
String response;
try {
HttpConnection http = new HttpConnection();
response = http.downloadFromFeed(requestPackage);
} catch (IOException e) {
//e.printStackTrace();
return;
}
Log.d(TAG, "Response -> " + response);
GsonBuilder builder = new GsonBuilder();
//builder.registerTypeAdapter(Uri.class, new JsonDeserializer<Uri>() {
// @Override
// public Uri deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
// return Uri.parse(json.toString());
// }
//});
Gson gson = builder.create();
RecipeList dataItems;
Type type = new TypeToken<RecipeList>() {
}.getType();
dataItems = gson.fromJson(response, type);
Intent messageIntent = new Intent(MY_SERVICE_MESSAGE);
messageIntent.putExtra(MY_SERVICE_RESPONSE_STRING, response);
// messageIntent.putExtra(MY_SERVICE_PAYLOAD, "Service all done!"); //pass data back, set key value and message
if (dataItems != null) {
//pass back the data
messageIntent.putExtra(MY_SERVICE_PAYLOAD, dataItems);
} else {
// unidentified sender - send empty parcel back
messageIntent.putExtra(MY_SERVICE_PAYLOAD, new Parcelable() {
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
}
});
//pass back the data
}
LocalBroadcastManager manager = LocalBroadcastManager.getInstance(getApplicationContext());
manager.sendBroadcast(messageIntent);
}
use of android.support.v4.content.LocalBroadcastManager in project facebook-api-android-maven by avianey.
the class BoltsMeasurementEventListener method open.
private void open() {
LocalBroadcastManager broadcastManager = LocalBroadcastManager.getInstance(applicationContext);
broadcastManager.registerReceiver(this, new IntentFilter(MEASUREMENT_EVENT_NOTIFICATION_NAME));
}
Aggregations