Android Open Source - Lolpaper Wallpaper Changed Reciever






From Project

Back to project page Lolpaper.

License

The source code is released under:

License THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE ...

If you think the Android project Lolpaper 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 hyoma.app.lollivewallpaper;
//from w  ww  . j  a v a 2 s  .  c  o m
import android.app.WallpaperManager;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;



public class WallpaperChangedReciever extends BroadcastReceiver  {

  @Override
  public void onReceive(Context ctx, Intent intent) {
    String action = intent.getAction();
    if(action.equals("android.intent.action.WALLPAPER_CHANGED")){
      if(StartLolpaperActivity.changeBGButton == true){
        Intent mordIntent = new Intent(WallpaperManager.ACTION_CHANGE_LIVE_WALLPAPER);  
        mordIntent.putExtra(WallpaperManager.EXTRA_LIVE_WALLPAPER_COMPONENT, new ComponentName(ctx, LolpaperService.class));
        mordIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // Needed to start an intent from outside an activity. 
        ctx.startActivity(mordIntent);
        StartLolpaperActivity.changeBGButton = false;
      }
      else if (StartLolpaperActivity.clearButton == true){
          // Reset the position to the centre of the screen. 
          SharedPreferences defPrefs = PreferenceManager.getDefaultSharedPreferences(ctx); 
          SharedPreferences.Editor prefsEditor = defPrefs.edit();
            
          Float totalHeight = defPrefs.getFloat(StartLolpaperActivity.totalHeight,-1);
          Float totalWidth = defPrefs.getFloat(StartLolpaperActivity.totalWidth,-1);
          
          if(totalHeight != -1 || totalWidth != -1){
            prefsEditor.putFloat(StartLolpaperActivity.X, totalWidth/2);
            prefsEditor.putFloat(StartLolpaperActivity.Y, totalHeight/2);
          }
          prefsEditor.commit();
          StartLolpaperActivity.clearButton = false;
      }
      }
  }
};




Java Source Code List

hyoma.app.lollivewallpaper.AnimationListXMLParser.java
hyoma.app.lollivewallpaper.AnimationSystem.java
hyoma.app.lollivewallpaper.AnimationsImageAdapter.java
hyoma.app.lollivewallpaper.CreateGridView.java
hyoma.app.lollivewallpaper.LolpaperService.java
hyoma.app.lollivewallpaper.SettingsActivity.java
hyoma.app.lollivewallpaper.SettingsFragment.java
hyoma.app.lollivewallpaper.StartLolpaperActivity.java
hyoma.app.lollivewallpaper.WallpaperChangedReciever.java