随着OkHttp图书馆,应用程序面临以下SocketTimeoutException问题.如果请求大小较小,那么它工作正常(小于1MB).我在10秒内收到此异常,即使我的socket timeout(readTimeout)值更高.它总是失败的请求(大小是1.8MB).当我执行请求时HttpUrlConnection它工作正常.什么可能是失败的原因?
03-29 12:16:38.997 32066-4018/com.mobile W/System.err: java.net.SocketTimeoutException: timeout
03-29 12:16:38.997 32066-4018/com.mobile W/System.err: at okio.Okio$3.newTimeoutException(Okio.java:207)
03-29 12:16:38.997 32066-4018/com.mobile W/System.err: at okio.AsyncTimeout.exit(AsyncTimeout.java:261)
03-29 12:16:38.997 32066-4018/com.mobile W/System.err: at okio.AsyncTimeout$1.write(AsyncTimeout.java:158)
03-29 12:16:38.997 32066-4018/com.mobile W/System.err: at okio.RealBufferedSink.emitCompleteSegments(RealBufferedSink.java:176)
03-29 12:16:38.997 32066-4018/com.mobile W/System.err: at okio.RealBufferedSink.write(RealBufferedSink.java:46)
03-29 12:16:38.997 32066-4018/com.mobile W/System.err: at okhttp3.internal.http.Http1xStream$FixedLengthSink.write(Http1xStream.java:286)
03-29 12:16:38.997 32066-4018/com.mobile W/System.err: at okio.RealBufferedSink.emitCompleteSegments(RealBufferedSink.java:176)
03-29 12:16:38.997 32066-4018/com.mobile W/System.err: at okio.RealBufferedSink.write(RealBufferedSink.java:96)
03-29 12:16:38.997 32066-4018/com.mobile W/System.err: at okhttp3.RequestBody$2.writeTo(RequestBody.java:96)
03-29 12:16:38.997 32066-4018/com.mobile W/System.err: at okhttp3.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:704)
03-29 12:16:38.997 32066-4018/com.mobile W/System.err: …Run Code Online (Sandbox Code Playgroud) 我在运行时下载了一个图像.现在我想将它设置为背景RelativeLayout.有可能吗?
我想应用一些字体说Times New Roman只适用于我的应用程序. 不是对整个系统而是对特定的观点.据我所知
要将字体应用于特定视图,我们将字体文件存储在资产文件夹中,并按如下方式进入应用程序.
1] Typeface mFace = Typeface.createFromAsset(getContext().getAssets(),
"fonts/samplefont.ttf");
textView.setTypeface(mFace);
2] To apply font to whole application I can replace the DroidSans.ttf file with my font file.
Run Code Online (Sandbox Code Playgroud)
我可以使用第一种方式将字体应用到我的应用程序,但它不是一个好的解决方案,因为我需要在任何地方进行修改,如果有更好的方法,我不想这样做.
我正在构建选项卡的应用程序.
@android:style/Theme.Dialog 一切正常,直到我不应用主题@android:style/Theme.Dialog
后应用主题我得到例外:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ebuilder/com.ebuilder.views.MyTabActivity}: java.lang.NullPointerException
Run Code Online (Sandbox Code Playgroud)
在以下行:
actionBar.addTab(actionBar.newTab().setCustomView(R.layout.tab_home).
setTabListener(homeListener), 0);
Run Code Online (Sandbox Code Playgroud)
我有两个问题:
1.如果我应用主题对话框会出现什么问题?
我的做法是对的吗?
如果有人知道另一种方法,请告诉我.
Edit1: *清单文件*
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.vivek"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:targetSdkVersion="14"/>
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".FragmentInsideFragmentTestActivity"
android:label="@string/app_name"
android:theme="@style/Theme.CustomDialog" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Run Code Online (Sandbox Code Playgroud)
RES /值/ style.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.CustomDialog" parent="android:style/Theme.Dialog">
<item name="android:windowNoTitle">false</item>
<item name="android:windowActionBar">true</item>
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
EDIT2
05-03 …Run Code Online (Sandbox Code Playgroud) 我在Linux控制台上运行服务器,用C语言编写并在android中创建客户端.我没有在DDMS上收到任何错误但是在调试消息之后
11-12 20:38:06.787: DEBUG/SntpClient(60): request time failed:
java.net.SocketException: Address family not supported by protocol
Run Code Online (Sandbox Code Playgroud)
但是消息不会发送到服务器.但是如果在C或java中创建客户端它工作正常.任何建议.
public class UDPDemo extends Activity {
private EditText mEditText;
private Button sendButton;
private DatagramSocket client_socket;
private static InetAddress IPAddress;
private byte[] send_data = new byte[1024];
static{
try {
IPAddress = InetAddress.getByName("127.0.0.1");
} catch (UnknownHostException e1) {
e1.printStackTrace();
}
}
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mEditText = (EditText)findViewById(R.id.EditText01);
sendButton = (Button)findViewById(R.id.Button01);
sendButton.setOnTouchListener( send);
} …Run Code Online (Sandbox Code Playgroud) 我想从android数据库中删除(例如手机号码).为此,我传递的查询如下
public class ContactDemo extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
String number = "2222";
Long id = getID(number);
int i = getContentResolver().delete(RawContacts.CONTENT_URI, RawContacts._ID+"=?", new String[]{id.toString()});
System.out.println("Deleted"+i);
}
public Long getID(String number){
Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(number));
Cursor c = getContentResolver().query(uri, new String[]{PhoneLookup._ID}, null, null, null);
while(c.moveToNext()){
return c.getLong(c.getColumnIndex(PhoneLookup._ID));
}
return null;
}
}
Run Code Online (Sandbox Code Playgroud)
但它正在删除整个联系人.
我应该使用什么来删除该电话号码(不是整个联系人)?
我有一个数据库文件和查询。使用这个我想生成房间实体。是否有可用的工具可以自动生成房间实体?
android ×7
android-room ×1
android-tabs ×1
contacts ×1
cursor ×1
java ×1
okhttp3 ×1
plugins ×1