当前位置: 首页>>代码示例>>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;未经允许,请勿转载。