Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/182.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 安卓更换壁纸_Android_Android 4.0 Ice Cream Sandwich_Wallpaper - Fatal编程技术网

Android 安卓更换壁纸

Android 安卓更换壁纸,android,android-4.0-ice-cream-sandwich,wallpaper,Android,Android 4.0 Ice Cream Sandwich,Wallpaper,我正在尝试更改galaxy sIII(ICS os)设备上的墙纸我正在使用1280x1440 jpeg图像,代码如下: <uses-permission android:name="android.permission.SET_WALLPAPER"/> .... Bitmap m = BitmapFactory.decodeByteArray(data, 0, data.length); WallpaperManager.getInstance(this).setBitmap(m

我正在尝试更改galaxy sIII(ICS os)设备上的墙纸我正在使用1280x1440 jpeg图像,代码如下:

<uses-permission android:name="android.permission.SET_WALLPAPER"/>

....

Bitmap m = BitmapFactory.decodeByteArray(data, 0, data.length);
WallpaperManager.getInstance(this).setBitmap(m);
但当我使用这个:

WallpaperManager.getInstance(this).setResource(data_img);
这是完美的工作,但我的情况是下载一些图像数据保存为位图,然后设置为壁纸。因此,在我的例子中,加载资源是不起作用的


任何帮助,请提前感谢。

您可以找到文档

您必须使用
public void setStream(输入流数据)
方法:

InputStream ins = new URL("absolute/path/of/image").openStream();
WallpaperManager wpm = WallpaperManager.getInstance(context);
wpm.setStream(ins);
或者,如果您有图像URI,则使用:

WallpaperManager wpm = WallpaperManager.getInstance(context);
wpm.setResource(Uri.of.image);

您可以找到文档

您必须使用
public void setStream(输入流数据)
方法:

InputStream ins = new URL("absolute/path/of/image").openStream();
WallpaperManager wpm = WallpaperManager.getInstance(context);
wpm.setStream(ins);
或者,如果您有图像URI,则使用:

WallpaperManager wpm = WallpaperManager.getInstance(context);
wpm.setResource(Uri.of.image);

谢谢@Tudor Luca工作很好

ins = new URL("file://"+Environment.getExternalStorageDirectory()+"/gst/chhota.jpg").openStream();
WallpaperManager wpm = WallpaperManager.getInstance(getBaseContext());
wpm.setStream(ins);

谢谢@Tudor Luca工作很好

ins = new URL("file://"+Environment.getExternalStorageDirectory()+"/gst/chhota.jpg").openStream();
WallpaperManager wpm = WallpaperManager.getInstance(getBaseContext());
wpm.setStream(ins);
试试这个

  private static boolean connectToNewWifiConfig(final WifiConfiguration wc, Context context)
    {
        wifi = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
        boolean success = false;
        final int actNetId = wifi.getConnectionInfo().getNetworkId();
        WifiInfo wifiInfo = wifi.getConnectionInfo();
        String prevNetworkSSID = wifiInfo.getSSID();
        int netId = wifi.addNetwork(wc);
        if (netId != ApplicationConstants.INVALID_NETWORK_ID)
        {
            success = wifi.saveConfiguration();
        }
        return success;
    }
它对我有效确保您通过正确的无线配置,无线配置将包含

wifiConfig = new WifiConfiguration();
        wifiConfig.SSID = "\"".concat(networkSSID).concat("\"");
        wifiConfig.status = WifiConfiguration.Status.ENABLED;
        wifiConfig.hiddenSSID = true;
        wifiConfig.priority = 40;
试试这个

  private static boolean connectToNewWifiConfig(final WifiConfiguration wc, Context context)
    {
        wifi = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
        boolean success = false;
        final int actNetId = wifi.getConnectionInfo().getNetworkId();
        WifiInfo wifiInfo = wifi.getConnectionInfo();
        String prevNetworkSSID = wifiInfo.getSSID();
        int netId = wifi.addNetwork(wc);
        if (netId != ApplicationConstants.INVALID_NETWORK_ID)
        {
            success = wifi.saveConfiguration();
        }
        return success;
    }
它对我有效确保您通过正确的无线配置,无线配置将包含

wifiConfig = new WifiConfiguration();
        wifiConfig.SSID = "\"".concat(networkSSID).concat("\"");
        wifiConfig.status = WifiConfiguration.Status.ENABLED;
        wifiConfig.hiddenSSID = true;
        wifiConfig.priority = 40;

你有什么例外吗??你有没有试着把日志语句放进去?你有什么异常吗??你有没有试着把日志语句放进去??