排行榜

  • 用户榜
  • 标签榜
  • 冲榜分奖金

频道

最新最热悬赏待采纳 筛选
  • 4

    回答

  • 18

    浏览

API21 activity.xml <?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <TextView android:id="@+id/timeview" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_horizontal" android:text="@string/TIME" android:textAppearance="@style/TextAppearance.AppCompat.Large" android:textSize="60sp" /> <Button android:id="@+id/buttonstart" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:onClick="onClickstart" android:text="@string/start" /> <Button android:id="@+id/buttonstop" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:onClick="onClickstop" android:text="@string/stop" /> <Button android:id="@+id/buttonreset" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:onClick="onClickreset" android:text="@string/reset" /> </LinearLayout> </androidx.constraintlayout.widget.ConstraintLayout> string.xml <resources> <string name="app_name">stopwatch</string> <string name="TIME">0:00;00</string> <string name="start">start</string> <string name="stop">stop</string> <string name="reset">reset</string> </resources> Mainactivity.java package com.e.stopwatch; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.os.Handler; import android.view.View; import android.widget.TextView; public class MainActivity extends AppCompatActivity { private int seconds=0; private boolean running=false; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); runtimer(); } public void onClickstart(View view){running=true;} public void onClickstop(View view){running=false;} public void onClickreset(View view){running=false;seconds=0;} private void runtimer(){ final TextView timeview=findViewById(R.id.timeview); final Handler handler=new Handler(); handler.post(new Runnable() { @Override public void run() { int hours=seconds/3600; int minutes=(seconds%3600)/60; int secs=seconds%60; String time=String.format("%d:%02d:02d%",hours,minutes,secs); timeview.setText(time); if (running){seconds++;} handler.postDelayed(this,1000); } }); } }  

  • 3

    回答

  • 17

    浏览

网上有教程,但是不管用,来一个真实的答案。或者教我下载eclipse的adt也行,

  • 5

    回答

  • 20

    浏览

1.使用java语句连接服务器上的mongodb数据库,首先连接成功,几毫秒后因出现套接字异常被断开连接 这是日志显示的  这是 mongdb的日志 确实有连接进来的日志显示 import java.util.List; import java.util.ArrayList; import java.util.List; import org.bson.types.ObjectId; import com.mongodb.BasicDBObject; import com.mongodb.DB; import com.mongodb.DBCollection; import com.mongodb.DBCursor; import com.mongodb.DBObject; import com.mongodb.Mongo; public class csdnconnect { static Mongo connection = null; static DB db = null; public void MongoDBUtil(String dbName) throws Exception { connection = new Mongo("47.114.149.208:27017"); db = connection.getDB(dbName); } public static Mongo getConnection() { return connection; } public List<String> findd(String collName) { DBCollection collection = db.getCollection(collName); DBCursor cursor =collection.find(); return convertCursorToList(cursor); } private List<String> convertCursorToList(DBCursor cursor) { List<String> results = new ArrayList<String>(); while(cursor.hasNext()) { DBObject dbObject = cursor.next(); for(String key : dbObject.keySet()) { results.add("{"+key+":"+dbObject.get(key)+"}"); } } return results; } }   这是 连接mongodb数据库的代码 包括连接和查询 import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.content.Context; import android.hardware.Sensor; import android.hardware.SensorEvent; import android.hardware.SensorEventListener; import android.hardware.SensorManager; import android.view.View; import java.util.List; public class MainActivity extends AppCompatActivity { private SensorManager sm; private Sensor mysensor; private StringBuffer sb = new StringBuffer(); private csdnconnect db = new csdnconnect(); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); System.out.println("wudi1"); sm = (SensorManager) getSystemService(Context.SENSOR_SERVICE); try { db.MongoDBUtil("mycol"); System.out.println("wudi2"); db.getConnection(); List<String> cursor=db.findd("mycol"); System.out.println("wudi3"); System.out.println(cursor); } catch (Exception e) { e.printStackTrace(); } } }    这是安卓代码mainactivity部分,数据库相关的只有try catch里面的内容,其实“wudi3”和cursor并没有输出   希望有大佬能帮我看看问题出在哪里

  • 4

    回答

  • 30

    浏览

有一个SharedPreferences的XML文件内容如下: <?xml version='1.0' encoding='utf-8' standalone='yes' ?> <map> <string name="三">3</string> <string name="四">4</string> <string name="九">9</string> <string name="七">7</string> <string name="一">1</string> <string name="八">8</string> <string name="二">2</string> <string name="五">5</string> <string name="六">6</string> </map>   我是有按照一二三四这样的顺序一项一项map.put()加上去的.结果储存时就变成以上那样,而再读出来再赋值到activity后就就乱了。 请问该如何能让他按原来的顺序储存好?

  • 6

    回答

  • 77

    浏览

Android studio如何通过多线程向列表添加新的数据, 我现在用的adpter在多线程里面生成的软件会停止运行

  • 4

    回答

  • 15

    浏览

org.litepal.exceptions.LitePalSupportException: java.util.List has no constructor. LitePal could not handle it   问题代码: List<MainBlock> mainBlocks = LitePal.findAll(MainBlock.class) ;

  • 6

    回答

  • 22

    浏览

这个是书上的案例,运行时创建数据库没有成功,红色的错误不知道错在哪里,哪位大佬能帮忙看看嘛,万分感谢

  • 2

    回答

  • 36

    浏览

我在本地IIS上发布了一个WebService,在浏览器可以正常访问但在安卓中不知如何调用。 以下是我的安卓代码,导入KSOAP3,建了一个KsoapHelper类 public class KsoapHelper { public static int timeOut = 30000; public static String webServiceUrl; public static String nameSpace; public static int soapVersion = 120; private KsoapHelper() { } public static void initKsoapHelper(String _webServiceUrl, String _nameSpace) { initKsoapHelper(timeOut, _webServiceUrl, _nameSpace, soapVersion); } public static void initKsoapHelper(String _webServiceUrl, String _nameSpace, int _version) { initKsoapHelper(timeOut, _webServiceUrl, _nameSpace, _version); } public static void initKsoapHelper(int _timeOut, String _webServiceUrl, String _nameSpace, int _version) { nameSpace = _nameSpace; webServiceUrl = _webServiceUrl; timeOut = _timeOut; soapVersion = _version; } public static SoapObject GetSoapObject(String methodName) { SoapObject object = new SoapObject(nameSpace, methodName); return object; } public static SoapObject GetSoapObject(String nameSpace, String methodName) { SoapObject object = new SoapObject(nameSpace, methodName); return object; } public static Object GetResult(SoapObject object, boolean isSimple) throws IOException, XmlPullParserException { SoapSerializationEnvelope sSEnvelope = new SoapSerializationEnvelope(120); sSEnvelope.bodyOut = object; sSEnvelope.dotNet = true; HttpTransportSE httpTransSE = new HttpTransportSE(webServiceUrl, timeOut); httpTransSE.debug = true; httpTransSE.call((String)null, sSEnvelope); SoapObject result; if (isSimple) { result = null; Object simpleResult = sSEnvelope.getResponse(); return simpleResult.toString(); } else { result = null; result = (SoapObject)sSEnvelope.getResponse(); SoapObject childs = (SoapObject)result.getProperty(1); return (SoapObject)childs.getProperty(0); } } }   private String WEBSERVICE_URL = "http://10.0.2.2:8081/WebService1.asmx?wsdl"; private String NAMESPACE = "localhost"; public String loginSQL( String name, String pass) throws IOException, XmlPullParserException { String result; KsoapHelper.initKsoapHelper(WEBSERVICE_URL, NAMESPACE); SoapObject request = KsoapHelper.GetSoapObject("Login"); // 设置需调用WebService接口需要传入的两个参数mobileCode、userId request.addProperty("name", name); request.addProperty("name", pass); result=(String) KsoapHelper.GetResult(request, false); return result; } 调用无法返回result的值,有大神可以帮忙看看是哪里出问题了吗?

  • 6

    回答

  • 73

    浏览

在Java和Android开发学习指南(第2版)ISBN 978-7-115-41753-4一书中看到一个关于无符号向右位移操作符的公式。 他是这么写的:如果n是负值,其结果取决于n的类型。如果n是一个int类型,结果的值是(n>>s)+(2<<~s)。如果n是一个long类型,结果的值是(n>>s)+(2L<<~s)。 我现在被这个公式搞得很迷,搜索了半天也没找到跟这个公式相关的东西,而且根据这个公式完全求不出来-9>>>1的结果,希望各位大佬能帮忙解答一下

  • 3

    回答

  • 25

    浏览

1 android.widget.Editor$SelectionModifierCursorController.access$300(Editor.java:6709) 2 android.widget.Editor.getEmailPopupWindow(Editor.java:1471) 3 android.widget.Editor.showEmailPopupWindow(Editor.java:1479) 4 android.widget.Editor.handleEmailPopup(Editor.java:1458) 5 android.widget.Editor.updateCursorPosition(Editor.java:2101) 6 android.widget.TextView.getUpdatedHighlightPath(TextView.java:7823) 7 android.widget.TextView.onDraw(TextView.java:8008) 8 android.view.View.draw(View.java:21473) 9 android.view.View.updateDisplayListIfDirty(View.java:20350) 10 android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4396) 11 android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4369) 12 android.view.View.updateDisplayListIfDirty(View.java:20310) 13 android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4396) 14 android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4369) 15 android.view.View.updateDisplayListIfDirty(View.java:20310) 16 android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4396) 17 android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4369) 18 android.view.View.updateDisplayListIfDirty(View.java:20310) 19 android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4396) 20 android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4369) 21 android.view.View.updateDisplayListIfDirty(View.java:20310) 22 android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4396) 23 android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4369) 24 android.view.View.updateDisplayListIfDirty(View.java:20310) 25 android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:575) 26 android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:581) 27 android.view.ThreadedRenderer.draw(ThreadedRenderer.java:654) 28 android.view.ViewRootImpl.draw(ViewRootImpl.java:3685) 29 android.view.ViewRootImpl.performDraw(ViewRootImpl.java:3480) 30 android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2817) 31 android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1780) 32 android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7752) 33 android.view.Choreographer$CallbackRecord.run(Choreographer.java:1031) 34 android.view.Choreographer.doCallbacks(Choreographer.java:854) 35 android.view.Choreographer.doFrame(Choreographer.java:789) 36 android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1016) 37 android.os.Handler.handleCallback(Handler.java:883) 38 android.os.Handler.dispatchMessage(Handler.java:100) 39 android.os.Looper.loop(Looper.java:224) 40 android.app.ActivityThread.main(ActivityThread.java:7542) 41 java.lang.reflect.Method.invoke(Native Method) 42 com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539) 43 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)   #137916 java.lang.NullPointerException Attempt to invoke direct method 'void android.widget.Editor$SelectionModifierCursorController.initDrawables()' on a null object reference android.widget.Editor$SelectionModifierCursorController.access$300(Editor.java:6709)

  • 7

    回答

  • 45

    浏览

E/AndroidRuntime: FATAL EXCEPTION: main     Process: com.example.administrator.library1, PID: 23102     java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.administrator.library1/com.example.administrator.library1.Student_homepage}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.example.administrator.library1.Student.getStudent_ID()' on a null object reference         at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3449)         at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601)         at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)         at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)         at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)         at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)         at android.os.Handler.dispatchMessage(Handler.java:106)         at android.os.Looper.loop(Looper.java:223)         at android.app.ActivityThread.main(ActivityThread.java:7656)         at java.lang.reflect.Method.invoke(Native Method)         at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)      Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.example.administrator.library1.Student.getStudent_ID()' on a null object reference         at com.example.administrator.library1.Student_homepage.onCreate(Student_homepage.java:60)         at android.app.Activity.performCreate(Activity.java:8000)         at android.app.Activity.performCreate(Activity.java:7984)         at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309)         at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3422)         at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601)          at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)          at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)          at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)          at android.os.Handler.dispatchMessage(Handler.java:106)          at android.os.Looper.loop(Looper.java:223)          at android.app.ActivityThread.main(ActivityThread.java:7656)          at java.lang.reflect.Method.invoke(Native Method)          at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)   

  • 3

    回答

  • 12

    浏览

如题 可以讲一下大致的思路或者从哪里可以学到相关知识么?

  • 3

    回答

  • 20

    浏览

D/EGL_emulation: eglMakeCurrent: 0xb2505120: ver 2 0 (tinfo 0xb2503200) D/EGL_emulation: eglMakeCurrent: 0xb2505120: ver 2 0 (tinfo 0xb2503200) D/EGL_emulation: eglMakeCurrent: 0xb2505120: ver 2 0 (tinfo 0xb2503200) D/EGL_emulation: eglMakeCurrent: 0xb2505120: ver 2 0 (tinfo 0xb2503200) E/MediaPlayer: Attempt to perform seekTo in wrong state: mPlayer=0x0, mCurrentState=1     error (-38, 0) E/MediaPlayer: Error (-38,0) W/MediaPlayer: Couldn't open http://192.168.0.104:8080/music/music2.mp3: java.io.FileNotFoundException: No content provider: http://192.168.0.104:8080/music/music2.mp3 I/art: Thread[3,tid=4671,WaitingInMainSignalCatcherLoop,Thread*=0xa42a3e00,peer=0x12c4b790,"Signal Catcher"]: reacting to signal 3 I/art: Wrote stack traces to '/data/anr/traces.txt' I/art: Thread[3,tid=4671,WaitingInMainSignalCatcherLoop,Thread*=0xa42a3e00,peer=0x12c4b790,"Signal Catcher"]: reacting to signal 3 I/art: Wrote stack traces to '/data/anr/traces.txt' E/MediaPlayer: error (1, -2147483648) D/MediaPlayer: create failed:     java.io.IOException: Prepare failed.: status=0x1         at android.media.MediaPlayer._prepare(Native Method)         at android.media.MediaPlayer.prepare(MediaPlayer.java:1184)         at android.media.MediaPlayer.create(MediaPlayer.java:878)         at android.media.MediaPlayer.create(MediaPlayer.java:851)

  • 1

    回答

  • 35

    浏览

直接修改的adapter ViewPager.setCurrentItem(theindex);导致此问题,请问MagicIndicato怎么直接修改指示器初始位置呢,完全找不到方法文档

  • 4

    回答

  • 33

    浏览

//获取当前天气 public void NowWeatherFill() { mHandler = new Handler.Callback() { @Override public boolean handleMessage(@NonNull Message msg) { String NowUrl = Constant.NOW_WEATHER_URL + "location=" + (String) msg.obj + "&key=" + Constant.API_KEY; HttpUtils.sendOkHttpRequest(NowUrl, new Callback() { @Override public void onFailure(Call call, IOException e) { ToastUtils.showShortToast(MainActivity.this,"错误"); } @Override public void onResponse(Call call, Response response) throws IOException { String responseData = response.body().string(); runOnUiThread(new Runnable() { @Override public void run() { Gson gson = new Gson(); NowWeatherBean nowWeatherBean = null; if (responseData != null && !responseData.isEmpty()) { nowWeatherBean = gson.fromJson(responseData, NowWeatherBean.class); tvTemperature.setText(nowWeatherBean.getNow().getTemp());//温度 String tempStr = "当前温度:" + nowWeatherBean.getNow().getTemp() + "度,天气" + nowWeatherBean.getNow().getText() + "。"; tvWeek.setText(DateUtils.getWeekOfDate(new Date()));//星期 tvInfo.setText(nowWeatherBean.getNow().getText());//天气状况 String time = DateUtils.updateTime(nowWeatherBean.getUpdateTime());//截去前面的字符,保留后面所有的字符,就剩下 22:00 tvOldTime.setText("最近更新时间:" + WeatherUtil.showTimeInfo(time) + time); tvWindDirection.setText("风向 " + nowWeatherBean.getNow().getWindDir());//风向 tvWindPower.setText("风力 " + nowWeatherBean.getNow().getWindScale() + "级");//风力 wwBig.startRotate();//大风车开始转动 wwSmall.startRotate();//小风车开始转动 }else{ ToastUtils.showShortToast(MainActivity.this,"错误"); } } }); } }); return false; } }; } //获取空气质量 public void AirQualityFill(){ mHandler = new Handler.Callback() { @Override public boolean handleMessage(@NonNull Message msg) { String NowUrl = Constant.AIRQUALITY_URL + "location=" + (String) msg.obj + "&key=" + Constant.API_KEY; HttpUtils.sendOkHttpRequest(NowUrl, new Callback() { @Override public void onFailure(Call call, IOException e) { ToastUtils.showShortToast(MainActivity.this,"错误"); } @Override public void onResponse(Call call, Response response) throws IOException { String responseData = response.body().string(); runOnUiThread(new Runnable() { @RequiresApi(api = Build.VERSION_CODES.M) @Override public void run() { Gson gson = new Gson(); Air_qualityBean air_qualityBean = null; if (responseData != null && !responseData.isEmpty()) { air_qualityBean = gson.fromJson(responseData, Air_qualityBean.class); String airStr = "空气质量:" + air_qualityBean.getNow().getAqi() + ",空气" + air_qualityBean.getNow().getCategory() + "。"; rpbAqi.setMaxProgress(300);//最大进度,用于计算 rpbAqi.setMinText("0");//设置显示最小值 rpbAqi.setMinTextSize(32f); rpbAqi.setMaxText("300");//设置显示最大值 rpbAqi.setMaxTextSize(32f); rpbAqi.setProgress(Float.valueOf(air_qualityBean.getNow().getAqi()));//当前进度 rpbAqi.setArcBgColor(getColor(R.color.arc_bg_color));//圆弧的颜色 rpbAqi.setProgressColor(getColor(R.color.arc_progress_color));//进度圆弧的颜色 rpbAqi.setFirstText(air_qualityBean.getNow().getCategory());//空气质量描述 取值范围:优,良,轻度污染,中度污染,重度污染,严重污染 rpbAqi.setFirstTextSize(44f);//第一行文本的字体大小 rpbAqi.setSecondText(air_qualityBean.getNow().getAqi());//空气质量值 rpbAqi.setSecondTextSize(64f);//第二行文本的字体大小 rpbAqi.setMinText("0"); rpbAqi.setMinTextColor(getColor(R.color.arc_progress_color)); tvAirInfo.setText("空气" + air_qualityBean.getNow().getCategory()); tvPm10.setText(air_qualityBean.getNow().getPm10());//PM10 tvPm25.setText(air_qualityBean.getNow().getPm2p5());//PM2.5 tvNo2.setText(air_qualityBean.getNow().getNo2());//二氧化氮 tvSo2.setText(air_qualityBean.getNow().getSo2());//二氧化硫 tvO3.setText(air_qualityBean.getNow().getO3());//臭氧 tvCo.setText(air_qualityBean.getNow().getCo());//一氧化碳 }else{ ToastUtils.showShortToast(MainActivity.this,"错误"); } } }); } }); return false; } }; } 最近自学Android,尝试做一个天气预报app,写了这两个方法,通过get请求获取数据,直接在 onCreate(Bundle savedInstanceState)方法里执行 但是这两个方法在执行中只执行了一个(谁在前面就执行谁)运行中也没有报错,感觉是不是线程阻塞了

  • 4

    回答

  • 24

    浏览

03-30 16:32:29.716 3367 3367 I wpa_supplicant: wlan0: CTRL-EVENT-DISCONNECTED bssid=78:2c:29:0e:f2:41 reason=3 locally_generated=1 一般安卓wifi断连会在日志中打印reason值,如何获取这个reason值呢 

  • 1

    回答

  • 15

    浏览

  • 3

    回答

  • 21

    浏览

   package com.example.fuck; import androidx.appcompat.app.AppCompatActivity; import android.annotation.SuppressLint; import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; import java.net.InetAddress; public class MainActivity extends AppCompatActivity implements View.OnClickListener{ private EditText et_host_name_this; private TextView tv_hos_name_this; private Button btn_host_name_this; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); initView(); } public void initView(){ et_host_name_this = (EditText) findViewById(R.id.et_host_name); tv_hos_name_this = (TextView) findViewById(R.id.tv_host_name); btn_host_name_this = (Button) findViewById(R.id.btn_host_name); btn_host_name_this.setOnClickListener(this::onClick); } @SuppressLint("HandlerLeak") private Handler mHandler = new Handler(){ @Override public void handleMessage(Message msg){ tv_hos_name_this.setText("主机检查结果如下:\n"+msg.obj); } }; public void onClick(View v){ if(v.getId()==R.id.btn_host_name){ new CheckThread(et_host_name_this.getText().toString()).start(); } } private class CheckThread extends Thread{ private String mHostName; public CheckThread(String host_name){ mHostName = host_name; Log.i("host_name",host_name); } @Override public void run(){ Log.i("host_name","1"); Message message = Message.obtain(); Log.i("host_name","2"); try { InetAddress host = InetAddress.getByName(mHostName); boolean isReachable = host.isReachable(5000); String desc = (isReachable)?"可以连接":"无法连接"; if(isReachable==true){ desc = String.format("%s\n主机名为%s\n主机地址为%s",desc,host.getHostName(),host.getHostAddress()); } message.what=0; message.obj=desc; }catch (Exception e){ e.printStackTrace(); message.what=-1; message.obj=e.getMessage(); } mHandler.sendMessage(message); } } }     主要问题就是当输入如www.bai.com时,回耗尽等待时间,然后结果连接不成功,但是电脑可以ping通www.baidu.com,有没有好心人解答一下,android sutdio4.1,模拟器为Pixel3 API 28,Android9.0 x86。结果图如下:  

  • 1

    回答

  • 13

    浏览

目前有的数据是,道路的矢量数据(一段一段,遇到转角切断有道路名称,起始点名称)、道路中心线的矢量数据(道路名称,道路中心线相交有交点),我要怎么判断那些道路线是可以通行的(行驶车辆时,左转、回头、直行、右转该如何判断)