當前位置: 首頁>>代碼示例>>Java>>正文


Java WallpaperManager.setStream方法代碼示例

本文整理匯總了Java中android.app.WallpaperManager.setStream方法的典型用法代碼示例。如果您正苦於以下問題:Java WallpaperManager.setStream方法的具體用法?Java WallpaperManager.setStream怎麽用?Java WallpaperManager.setStream使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.app.WallpaperManager的用法示例。


在下文中一共展示了WallpaperManager.setStream方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setWallpaper

import android.app.WallpaperManager; //導入方法依賴的package包/類
private void setWallpaper() {
    try {
        WallpaperManager wallpaperManager = WallpaperManager.getInstance(this);
        InputStream inputStream = getContentResolver().openInputStream(imageUri);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
            Rect croppedRect = getCroppedRect();
            wallpaperManager.setStream(inputStream, croppedRect, true);
        } else {
            wallpaperManager.setStream(inputStream);
        }

        SubsamplingScaleImageView imageView = findViewById(R.id.imageView);
        imageView.recycle();

        this.finish();
    } catch (IOException | IllegalArgumentException e) {
        e.printStackTrace();
        Toast.makeText(this, R.string.error, Toast.LENGTH_SHORT).show();
    }
}
 
開發者ID:kollerlukas,項目名稱:Camera-Roll-Android-App,代碼行數:21,代碼來源:SetWallpaperActivity.java

示例2: toSetWallPage

import android.app.WallpaperManager; //導入方法依賴的package包/類
private void toSetWallPage(Uri data) {
    WallpaperManager wallpaperManager = WallpaperManager.getInstance(mActivity);
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT){
        File wallpageFile = new File(data.getPath());
        Uri contentUri = getImageContentUri(mActivity,wallpageFile.getAbsolutePath());
        mActivity.startActivity(wallpaperManager.getCropAndSetWallpaperIntent(contentUri));
    }else{
        try {
            wallpaperManager.setStream(mActivity.getContentResolver().openInputStream(data));
            mView.showMsg(MyApplication.getInstance().getString(R.string.set_wallpaper_success));
        } catch (IOException e) {
            e.printStackTrace();
            mView.showMsg(e.getMessage());
        }
    }
}
 
開發者ID:LuoboDcom,項目名稱:ZZShow,代碼行數:17,代碼來源:PhotoDetailPresenterImpl.java

示例3: doInBackground

import android.app.WallpaperManager; //導入方法依賴的package包/類
@Override
protected String doInBackground(final Void... params) {
    try {
        mPhotoPosition = mPhotoAdapter.getPosition();
        String url = mPhotoAdapter.getPhotoList().get(mPhotoPosition)
                .url;
        url = url.replace(".webp", "_o" + ".webp");
        WallpaperManager wpm = WallpaperManager
                .getInstance(getActivity().getApplicationContext());
        InputStream ins = new URL(url).openStream();
        wpm.setStream(ins);
        return null;
    } catch (IOException e) {
        return getString(R.string.wallpaper_error);
    }
}
 
開發者ID:googlearchive,項目名稱:abelana,代碼行數:17,代碼來源:PicturesFragment.java

示例4: setWallPaper

import android.app.WallpaperManager; //導入方法依賴的package包/類
private static boolean setWallPaper(Context context,String data){
    WallpaperManager mWallManager=WallpaperManager.getInstance(context);
    try {
        File file = Glide.with(context).load(data).downloadOnly(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL).get();
        mWallManager.setStream(new FileInputStream(file));
        return true;
    }
    catch (Exception e) {
        e.printStackTrace();
        return false;
    }
}
 
開發者ID:zjutkz,項目名稱:AgeraBeauty,代碼行數:13,代碼來源:WallPaperUtils.java

示例5: onReceive

import android.app.WallpaperManager; //導入方法依賴的package包/類
@Override
public void onReceive(final Context context, Intent intent) {
    mPrefs = new PreferenceDao(context);

    String action = intent.getAction();
    if (Intent.ACTION_BOOT_COMPLETED.equals(action)) {
        Log.v(TAG, "端末起動完了");

        if (mPrefs.isAutoWallpaperEnabled()) {
            startPolling(context);
        }
    } else if (ACTION_CHANGE_WALLPAPER.equals(action)) {
        try {
            File imageDir = new RequestDownloadImage(context).getImageDir();

            // どの畫像を表示するのかを選択
            String filePath = nextWallpaperPath(imageDir);
            if (TextUtils.isEmpty(filePath)) {
                // 表示する畫像がなかった場合
                Log.i(TAG, "壁紙がまだダウンロードされていない");
                return;
            }

            // 壁紙の変更を行う
            InputStream wpStream = new FileInputStream(filePath);
            WallpaperManager wm = WallpaperManager.getInstance(context);
            wm.setStream(wpStream);
            wpStream.close();

            Log.v(TAG, "壁紙変更完了");
        } catch (IOException e) {
            Log.e(TAG, "壁紙の変更に失敗", e);
        }
    }
}
 
開發者ID:yokmama,項目名稱:honki_android2,代碼行數:36,代碼來源:WallpaperBroadcastReceiver.java

示例6: setStream

import android.app.WallpaperManager; //導入方法依賴的package包/類
public static void setStream(Context context, final InputStream data, Rect visibleCropHint,
        boolean allowBackup, int whichWallpaper) throws IOException {
    WallpaperManager wallpaperManager = WallpaperManager.getInstance(context);
    if (Utilities.ATLEAST_N) {
        wallpaperManager.setStream(data, visibleCropHint, allowBackup, whichWallpaper);
    } else {
        // Fall back to previous implementation (set system)
        wallpaperManager.setStream(data);
    }
}
 
開發者ID:RunasSudo,項目名稱:FLauncher,代碼行數:11,代碼來源:NycWallpaperUtils.java

示例7: doInBackground

import android.app.WallpaperManager; //導入方法依賴的package包/類
@Override
            protected Void doInBackground(Object... objects) {

                DisplayMetrics metrics = new DisplayMetrics();
                getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics);
                int height = metrics.heightPixels;
                int width = metrics.widthPixels;

                WallpaperManager wallpaperManager = WallpaperManager.getInstance(getActivity());
                wallpaperManager.setWallpaperOffsetSteps(1, 1);
                wallpaperManager.suggestDesiredDimensions(width, height);

                try {
                    String urlWalpaper = urlImage.replace("/r_10000_" + getActivity().getResources().getInteger(R.integer.fragment_movie_fond_height), "/r_" + (width) + "_" + (height));
                    wallpaperManager.setStream(new URL(urlWalpaper).openStream());


                     /*   Bitmap bmap2 = BitmapFactory.decodeStream(new URL(urlWalpaper).openStream());

                        DisplayMetrics metrics = new DisplayMetrics();
                        activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
                        int height = metrics.heightPixels;
                        int width = metrics.widthPixels;
                        Bitmap bitmap = Bitmap.createScaledBitmap(bmap2, width, height, true);
activity.setWallpaper(bitmap);
                           // wallpaperManager.setBitmap(bitmap);
*/

                } catch (Exception e) {
                    if (e.getMessage() != null)
                        e.printStackTrace();
                }

                return null;
            }
 
開發者ID:florent37,項目名稱:OCiney,代碼行數:36,代碼來源:ImagesPagerAdapter.java

示例8: setWallpaper

import android.app.WallpaperManager; //導入方法依賴的package包/類
protected void setWallpaper() {
    InputStream inputStream = processImage(mActivityResultData);
    WallpaperManager myWallpaperManager
            = WallpaperManager.getInstance(getApplicationContext());
    try {
        myWallpaperManager.setStream(inputStream);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
開發者ID:dcf82,項目名稱:PicDrawerApp,代碼行數:11,代碼來源:MainActivity.java


注:本文中的android.app.WallpaperManager.setStream方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。