List of usage examples for android.app WallpaperManager setResource
@RequiresPermission(android.Manifest.permission.SET_WALLPAPER) public void setResource(@RawRes int resid) throws IOException
From source file:com.designrifts.ultimatethemeui.fragments.FragmentTheme.java
private void applyNovaTheme() { WallpaperManager setDefaultWallpaper = WallpaperManager.getInstance(getActivity().getApplicationContext()); try {/*from ww w . j a v a2s . c o m*/ Intent novalauncherIntent = new Intent(ACTION_APPLY_ICON_THEME); novalauncherIntent.setPackage(NOVA_PACKAGE); novalauncherIntent.putExtra(EXTRA_ICON_THEME_TYPE, "GO"); novalauncherIntent.putExtra(EXTRA_ICON_THEME_PACKAGE, getActivity().getPackageName()); startActivity(novalauncherIntent); setDefaultWallpaper.setResource(R.drawable.wallpaper_default); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } //finish(); }
From source file:com.designrifts.ultimatethemeui.fragments.FragmentTheme.java
private void applySmartTheme() { WallpaperManager setDefaultWallpaper = WallpaperManager.getInstance(getActivity().getApplicationContext()); try {//from w w w . j a v a 2 s .co m Intent smart = getActivity().getPackageManager().getLaunchIntentForPackage("ginlemon.flowerfree"); Intent smartpro = getActivity().getPackageManager().getLaunchIntentForPackage("ginlemon.flowerpro"); if (smart != null) { Intent smartlauncherIntent = new Intent(SMART_PACKAGE); smartlauncherIntent.putExtra("package", getActivity().getPackageName()); startActivity(smartlauncherIntent); setDefaultWallpaper.setResource(R.drawable.wallpaper_default); } else if (smartpro != null) { Intent smartlauncherIntent = new Intent(SMART_PACKAGE); smartlauncherIntent.putExtra("package", getActivity().getPackageName()); startActivity(smartlauncherIntent); setDefaultWallpaper.setResource(R.drawable.wallpaper_default); } else { // Direct users to get Smart Launcher String playStoreUrl = "https://play.google.com/store/apps/details?id=ginlemon.flowerfree"; startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(playStoreUrl))); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } //finish(); }
From source file:com.chale22.ico01.fragments.FragmentTheme.java
private void applySmartTheme() { WallpaperManager setDefaultWallpaper = WallpaperManager.getInstance(getActivity().getApplicationContext()); try {/* w ww .j av a 2 s .c o m*/ Intent smart = getActivity().getPackageManager().getLaunchIntentForPackage("ginlemon.flowerfree"); Intent smartpro = getActivity().getPackageManager().getLaunchIntentForPackage("ginlemon.flowerpro"); if (smart != null) { Intent smartlauncherIntent = new Intent(SMART_PACKAGE); smartlauncherIntent.putExtra("package", getActivity().getPackageName()); startActivity(smartlauncherIntent); setDefaultWallpaper.setResource(R.drawable.wall_1); } else if (smartpro != null) { Intent smartlauncherIntent = new Intent(SMART_PACKAGE); smartlauncherIntent.putExtra("package", getActivity().getPackageName()); startActivity(smartlauncherIntent); setDefaultWallpaper.setResource(R.drawable.wall_1); } else { // Direct users to get Smart Launcher String playStoreUrl = "https://play.google.com/store/apps/details?id=ginlemon.flowerfree"; startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(playStoreUrl))); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } //finish(); }
From source file:com.pk.wallpapermanager.PkWallpaperManager.java
/** * Sets the system wallpaper to the Wallpaper object passed. * May throw an exception if the data is invalid. * <p>//from w ww . j a va 2 s .c o m * Note: Do NOT call this from the main UI thread if you're * setting it to a cloud wallpaper! Call setWallpaperAsync instead. * * @param mWall * @throws NumberFormatException * @throws IOException */ public void setWallpaper(Wallpaper mWall) throws NumberFormatException, IOException { if (debugEnabled) Log.d(LOG_TAG, "Setting wallpaper..."); // Load the original system WallpaperManager WallpaperManager wallManager = WallpaperManager.getInstance(mContext); Bitmap bitmap = null; // Set resource if local, otherwise download it and set it if (mWall.isLocal()) wallManager.setResource(mWall.getFullResource()); else { bitmap = getBitmapFromURL(mWall.getFullURL()); wallManager.setBitmap(bitmap); } // Loop through all listeners notifying them for (WallpaperSetListener mListener : mWallpaperSetListeners) { mListener.onWallpaperSet(bitmap); } if (debugEnabled) Log.d(LOG_TAG, "Successfully set wallpaper!"); }
From source file:com.android.launcher3.Launcher.java
@Override protected void onCreate(Bundle savedInstanceState) { if (DEBUG_STRICT_MODE) { StrictMode.setThreadPolicy(/* w ww. j a v a 2 s. c om*/ new StrictMode.ThreadPolicy.Builder().detectDiskReads().detectDiskWrites().detectNetwork() // or .detectAll() for all detectable problems .penaltyLog().build()); StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectLeakedSqlLiteObjects() .detectLeakedClosableObjects().penaltyLog().penaltyDeath().build()); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { if (LauncherAppState.PROFILE_STARTUP) { Trace.beginSection("Launcher-onCreate"); } } predictiveAppsProvider = new PredictiveAppsProvider(this); if (mLauncherCallbacks != null) { mLauncherCallbacks.preOnCreate(); } super.onCreate(savedInstanceState); app = LauncherAppState.getInstance(); // Load configuration-specific DeviceProfile mDeviceProfile = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE ? app.getInvariantDeviceProfile().landscapeProfile : app.getInvariantDeviceProfile().portraitProfile; mSharedPrefs = Utilities.getPrefs(this); mIsSafeModeEnabled = getPackageManager().isSafeMode(); mModel = app.setLauncher(this); mIconCache = app.getIconCache(); mAccessibilityDelegate = new LauncherAccessibilityDelegate(this); mDragController = new DragController(this); mAllAppsController = new AllAppsTransitionController(this); mStateTransitionAnimation = new LauncherStateTransitionAnimation(this, mAllAppsController); mAppWidgetManager = AppWidgetManagerCompat.getInstance(this); mAppWidgetHost = new LauncherAppWidgetHost(this, APPWIDGET_HOST_ID); mAppWidgetHost.startListening(); // If we are getting an onCreate, we can actually preempt onResume and unset mPaused here, // this also ensures that any synchronous binding below doesn't re-trigger another // LauncherModel load. mPaused = false; setContentView(R.layout.launcher); //Shortcuts variable init masterLayout = (InsettableFrameLayout) findViewById(R.id.launcher); gridSize = new GridSize((int) app.getInvariantDeviceProfile().numColumns, (int) app.getInvariantDeviceProfile().numRows); IS_ALLOW_MIC = Utilities.isAllowVoiceInSearchBarPrefEnabled(getApplicationContext()); setupViews(); mDeviceProfile.layout(this, false /* notifyListeners */); mExtractedColors = new ExtractedColors(); loadExtractedColorsAndColorItems(); ((AccessibilityManager) getSystemService(ACCESSIBILITY_SERVICE)).addAccessibilityStateChangeListener(this); lockAllApps(); mSavedState = savedInstanceState; restoreState(mSavedState); if (LauncherAppState.PROFILE_STARTUP) { Trace.endSection(); } // We only load the page synchronously if the user rotates (or triggers a // configuration change) while launcher is in the foreground if (!mModel.startLoader(mWorkspace.getRestorePage())) { // If we are not binding synchronously, show a fade in animation when // the first page bind completes. mDragLayer.setAlpha(0); } else { setWorkspaceLoading(true); } // For handling default keys mDefaultKeySsb = new SpannableStringBuilder(); Selection.setSelection(mDefaultKeySsb, 0); IntentFilter filter = new IntentFilter(ACTION_APPWIDGET_HOST_RESET); registerReceiver(mUiBroadcastReceiver, filter); mRotationEnabled = getResources().getBoolean(R.bool.allow_rotation); // In case we are on a device with locked rotation, we should look at preferences to check // if the user has specifically allowed rotation. if (!mRotationEnabled) { mRotationEnabled = Utilities.isAllowRotationPrefEnabled(getApplicationContext()); mRotationPrefChangeHandler = new RotationPrefChangeHandler(); mSharedPrefs.registerOnSharedPreferenceChangeListener(mRotationPrefChangeHandler); } // On large interfaces, or on devices that a user has specifically enabled screen rotation, // we want the screen to auto-rotate based on the current orientation setOrientation(); if (mLauncherCallbacks != null) { mLauncherCallbacks.onCreate(savedInstanceState); } activity = this; /*if (!isTaskRoot()) { finish(); return; }*/ adminComponent = new ComponentName(Launcher.this, DarClass.class); devicePolicyManager = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE); appHasFingerprint = Utilities.getAppHasFingerprint(getApplicationContext()); appHasPassword = Utilities.getAppHasPassword(getApplicationContext()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { fingerprintManager = (FingerprintManager) getSystemService(FINGERPRINT_SERVICE); } icons = Utilities.getIconPack(Utilities.getAppIconPackageNamePrefEnabled(getApplicationContext())); if (icons == null || icons.isEmpty() || icons.size() == 0) { if (Utilities.getAppIconPackageNamePrefEnabled(getApplicationContext()) != null && !Utilities .getAppIconPackageNamePrefEnabled(getApplicationContext()).equalsIgnoreCase("NULL")) { Utilities.answerToRestoreIconPack(this, Utilities.getAppIconPackageNamePrefEnabled(getApplicationContext())); } } if (FirstRun.isFirstLaunch(getApplicationContext())) { WallpaperManager myWallpaperManager = WallpaperManager.getInstance(getApplicationContext()); try { myWallpaperManager.setResource(R.drawable.wallpaper); } catch (IOException e) { e.printStackTrace(); } } if (Utilities.doCheckPROVersion(getApplicationContext())) { } mDefaultScreenId = Utilities.getLongCustomDefault(this, Utilities.SETTINGS_UI_HOMESCREEN_DEFAULT_SCREEN_ID, 1); }