Android Open Source - salaya-tram-map Misc Widget Broadcast Receiver






From Project

Back to project page salaya-tram-map.

License

The source code is released under:

Unless otherwise noted, this software is Copyright 2011 Pawit Pornkitprasan and is licensed under the Simplified BSD License. Copyright 2011 Pawit Pornkitprasan. All rights reserved. Red...

If you think the Android project salaya-tram-map listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package org.dyndns.pawitp.salayatrammap;
//from  ww w. ja v  a2s  .c o  m
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.util.Log;

// Disableable broadcast receiver to receive broadcasts which only applies while widget is running
public class MiscWidgetBroadcastReceiver extends BroadcastReceiver {

  private static final String TAG = "MiscWidgetBroadcastReceiver";
  
  public static final String UPDATE_WIDGET_IF_ENABLED_INTENT = "org.dyndns.pawitp.salayatrammap.UPDATE_WIDGET_IF_ENABLED";
  
  @Override
  public void onReceive(Context context, Intent intent) {
    String action = intent.getAction();
    
    Log.v(TAG, action);
    
    if (UPDATE_WIDGET_IF_ENABLED_INTENT.equals(action) || 
      Intent.ACTION_TIME_CHANGED.equals(action)) {
      Intent i = new Intent(TramScheduleWidgetProvider.UPDATE_INTENT);
      context.sendBroadcast(i);
    }
  }

  public static void setEnabled(Context context, boolean enabled) {  
    ComponentName receiver = new ComponentName(context, MiscWidgetBroadcastReceiver.class);
    int state = enabled ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED : PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
    context.getPackageManager().setComponentEnabledSetting(receiver, state, PackageManager.DONT_KILL_APP);
  }
  
}




Java Source Code List

org.dyndns.pawitp.salayatrammap.MainActivity.java
org.dyndns.pawitp.salayatrammap.MiscWidgetBroadcastReceiver.java
org.dyndns.pawitp.salayatrammap.TramScheduleWidgetProvider.java
org.dyndns.pawitp.salayatrammap.Utils.java
org.dyndns.pawitp.salayatrammap.map.MapView.java
org.dyndns.pawitp.salayatrammap.map.NoStopMatchedException.java
org.dyndns.pawitp.salayatrammap.map.SearchSuggestionProvider.java
org.dyndns.pawitp.salayatrammap.map.TramDbHelper.java
org.dyndns.pawitp.salayatrammap.map.Zoomer.java
org.dyndns.pawitp.salayatrammap.schedule.NoMoreTramException.java
org.dyndns.pawitp.salayatrammap.schedule.NoTramLeftException.java
org.dyndns.pawitp.salayatrammap.schedule.TramCarSchedule.java
org.dyndns.pawitp.salayatrammap.schedule.TramException.java
org.dyndns.pawitp.salayatrammap.schedule.TramsSchedule.java