(Android 4.0.3用に)壁紙を作成しましたが、設定に問題があります。
http-get
からサービスを呼び出そうとするとPreferenceFragment
、応答がありません。実際には、通話が失われたようです。私は次のような電話で試しました:
InputStream stream = null;
StringBuilder fos = null;
try {
URL url = new URL("http://.....");
stream = url.openConnection().getInputStream();
InputStreamReader reader = new InputStreamReader(stream);
fos = new StringBuilder();
int next = -1;
while ((next = reader.read()) != -1) {
fos.append((char)next);
}
} catch (Exception e) {
// ...
} finally {
// ...
}
または次のような外部フレームワークを使用しlibgdx
ます。
HttpRequest httpRequest = new HttpRequest(HttpMethods.GET);
httpRequest.setUrl("http://.....");
NetJavaImpl net = new NetJavaImpl();
net.sendHttpRequest(httpRequest, this);
しかし、何も起こりませんでした。デバイスには、これに関するトレースまたは確率例外は存在しません。
私はこのようなマニフェストを持っています:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="it.mytest.live"
android:installLocation="preferExternal"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.SET_WALLPAPER" />
<uses-feature
android:name="android.software.live_wallpaper"
android:required="true" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".MyWallpaperSettings"
android:exported="true"
android:hardwareAccelerated="false"
android:label="MyWallpaperSettings"
android:permission="android.permission.INTERNET" />
<service
android:name=".MyWallpaper"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:permission="android.permission.BIND_WALLPAPER" >
<intent-filter>
<action android:name="android.service.wallpaper.WallpaperService" />
</intent-filter>
<meta-data
android:name="android.service.wallpaper"
android:resource="@xml/livewallpaper"
android:value="true" />
</service>
</application>
</manifest>
何か考えはありますか?私はおかしくなりそうだ :(
*編集:解決しました、ありがとう!! *
private class SendAsyncTask extends AsyncTask<String, String, String>
{
protected String doInBackground(String... status)
{
String result = "";
try
{
String url = "my magic http-get";
HttpClient httpclient = new DefaultHttpClient();
HttpResponse response = httpclient.execute(new HttpGet(url));
if(response != null && response.getEntity() != null)
{
InputStream stream = response.getEntity().getContent();
try
{
// parse an XML with libgdx ...
XmlReader xmlReader = new XmlReader();
Element root = xmlReader.parse(stream);
Array<Element> childs = root.getChildrenByNameRecursively("mykids");
for (Element child: childs)
{
Element myelement = child.getChildByName("name");
//do something...
}
}
catch (Exception e)
{
//
}
finally
{
try
{
stream.close();
}
catch (Exception e)
{
//
}
}
}
}
catch (Exception e)
{
//
}
return result;
}
protected void onPostExecute(String result)
{
super.onPostExecute(result);
}
}