- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试列出我在我的 Android 应用程序中发现的一些 JmDNS 服务,但每当我调用此方法时,我的应用程序就会在模拟器中崩溃?我尝试注释掉代码块和方法内的代码,但它仍然在模拟器上崩溃。有人有什么想法吗?
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import javax.jmdns.JmDNS;
import javax.jmdns.ServiceInfo;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo.State;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.Toast;
/**
* The main activity, which list the available services in the local network.
*
*/
public class ConnectActivity extends Activity {
private final static String LOG_TAG = ConnectActivity.class.getSimpleName();
// ===================View Models===================
// The view model of the service info list
private List<ServiceInfoViewModel> serviceInfoList = new ArrayList<ServiceInfoViewModel>();
private ServiceServer server = null;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.connect);
this.initViewModels();
this.initEventHandlers();
this.initMockData();
if (!checkWifiStatus()) {
// this.showToast("No wifi network!");
}
server = new ServiceServer("Whooznear");
int startedPort = server.start();
Log.i(LOG_TAG, "Started at " + startedPort);
ScheduledExecutorService scheduleTaskExecutor = Executors.newScheduledThreadPool(5);
// This schedule a runnable task every second
scheduleTaskExecutor.scheduleAtFixedRate(new Runnable() {
public void run() {
//Put Thread Code Here
//refreshServices();
}
}, 0, 1, TimeUnit.SECONDS);
}
private void refreshServices() {
new Thread(new Runnable() {
public void run() {
Log.i(LOG_TAG, "refresh services...");
testUpdateService();
JmDNS registry = null;
try {
registry = JmDNS.create();
List<String> enabledServices = LocalEnvironment
.getEnabledServices(ConnectActivity.this);
for (String serviceName : enabledServices) {
String serviceType = LocalEnvironment
.getServiceTypeByTitle(serviceName);
Log.i(LOG_TAG, "Register service..." + serviceType);
String text = "Test service";
Map<String, byte[]> properties = new HashMap<String, byte[]>();
properties.put("srvname", text.getBytes());
ServiceInfo service = ServiceInfo.create(serviceType,
"apache-someuniqueid", 80, 0, 0, true,
properties);
registry.registerService(service);
Log.i(LOG_TAG, "List service..." + service.getType());
final ServiceInfo[] services = registry.list(service
.getType());
Log.i(LOG_TAG, services.length + " services ("
+ serviceType + ") is found.");
ConnectActivity.this.runOnUiThread(new Runnable() {
public void run() {
for (ServiceInfo service : services) {
serviceInfoList
.add(new ServiceInfoViewModel(service));
}
notifyServiceListChanged();
}
});
}
} catch (Exception ex) {
ex.printStackTrace();
Log.e(LOG_TAG, ex.toString());
}
}
}).start();
}
private void onRefreshButtonClicked(View source) {
this.showToast("Clicked " + ((Button) source).getText());
this.refreshServices();
}
/*private void onSettingsButtonClicked(View source) {
Intent intent = new Intent();
intent.setClass(this, SettingsActivity.class);
this.startActivityForResult(intent, RESULT_OK);
}*/
private void onServiceListItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
ServiceInfoViewModel selectedService = serviceInfoList.get(arg2);
Log.i(LOG_TAG, "Selected service at " + selectedService.getServiceIp());
Intent intent = new Intent();
intent.putExtra("ServiceName", selectedService.getServiceName());
intent.putExtra("ServiceAddress", selectedService.getServiceIp());
intent.setClass(this, ProfileActivity.class);
this.startActivityForResult(intent, RESULT_OK);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
switch (resultCode) {
case RESULT_OK:
break;
default:
break;
}
}
private void initViewModels() {
ListView servicesListView = (ListView) this
.findViewById(R.id.servicesListView);
ListAdapter servicesListAdapter = new SimpleAdapter(this,
serviceInfoList, android.R.layout.simple_list_item_2,
new String[] { "serviceName", "serviceDesc" }, new int[] {
android.R.id.text1, android.R.id.text2 });
servicesListView.setAdapter(servicesListAdapter);
}
/**
* Initialize the event handlers
*/
private void initEventHandlers() {
// Service List View
ListView servicesListView = (ListView) this
.findViewById(R.id.servicesListView);
servicesListView
.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
onServiceListItemSelected(arg0, arg1, arg2, arg3);
}
});
// Refresh Button
/*Button refreshButton = (Button) this
.findViewById(R.id.refreshServiceButton);
refreshButton.setOnClickListener(new Button.OnClickListener() {
public void onClick(View source) {
onRefreshButtonClicked(source);
}
});*/
// Settings Button
/*Button settingsButton = (Button) this
.findViewById(R.id.appSettingsButton);
settingsButton.setOnClickListener(new Button.OnClickListener() {
public void onClick(View source) {
onSettingsButtonClicked(source);
}
});*/
}
private void initMockData() {
}
private boolean checkWifiStatus() {
try {
ConnectivityManager conMan = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); // Network
State wifiState = conMan.getNetworkInfo(
ConnectivityManager.TYPE_WIFI).getState();
WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
WifiInfo info = wifi.getConnectionInfo();
Log.i(LOG_TAG, "IP Address:" + info.getIpAddress());
LocalEnvironment.LocalIPAddress = info.getIpAddress();
LocalEnvironment.LocalIdentity = info.getMacAddress();
return wifiState == State.CONNECTED;
} catch (Exception ex) {
Log.e(this.getClass().getName(), "Check Wifi Status Failed!", ex);
this.showToast(ex.toString());
return false;
}
}
private void notifyServiceListChanged() {
ListView servicesListView = (ListView) this
.findViewById(R.id.servicesListView);
((SimpleAdapter) servicesListView.getAdapter()).notifyDataSetChanged();
}
private void testUpdateService() {
String text = "Test hypothetical web server";
Map<String, byte[]> properties = new HashMap<String, byte[]>();
properties.put("srvname", text.getBytes());
ServiceInfo service = ServiceInfo.create("_html._tcp.local.",
"apache-someuniqueid", 80, 0, 0, true, properties);
JmDNS registry = null;
Exception occuredEx = null;
int serviceCount = 0;
try {
registry = JmDNS.create();
registry.registerService(service);
ServiceInfo[] services = registry.list(service.getType());
serviceCount = services.length;
Log.d(LOG_TAG, serviceCount + " services found");
} catch (IOException ex) {
this.showToast(ex.toString());
occuredEx = ex;
} finally {
if (registry != null) {
try {
registry.close();
} catch (IOException ex) {
this.showToast(ex.toString());
occuredEx = ex;
}
}
}
}
private void showToast(String text) {
Toast.makeText(this, text, Toast.LENGTH_SHORT).show();
}
private void showToast(int id) {
ListView servicesListView = (ListView) this
.findViewById(R.id.servicesListView);
Toast.makeText(this, servicesListView.getItemAtPosition(id).toString(),
Toast.LENGTH_SHORT).show();
}
}
这是我用来调用上述方法的代码:
Intent myIntent = new Intent(ProfileActivity.this, ConnectActivity.class);
ProfileActivity.this.startActivity(myIntent);
这是堆栈跟踪:
01-09 23:42:39.951: E/com.whooznear.android.ConnectActivity(1532): Check Wifi Status Failed!
01-09 23:42:39.951: E/com.whooznear.android.ConnectActivity(1532): java.lang.SecurityException: ConnectivityService: Neither user 10036 nor current process has android.permission.ACCESS_NETWORK_STATE.
01-09 23:42:39.951: E/com.whooznear.android.ConnectActivity(1532): at android.os.Parcel.readException(Parcel.java:1321)
01-09 23:42:39.951: E/com.whooznear.android.ConnectActivity(1532): at android.os.Parcel.readException(Parcel.java:1275)
01-09 23:42:39.951: E/com.whooznear.android.ConnectActivity(1532): at android.net.IConnectivityManager$Stub$Proxy.getNetworkInfo(IConnectivityManager.java:469)
01-09 23:42:39.951: E/com.whooznear.android.ConnectActivity(1532): at android.net.ConnectivityManager.getNetworkInfo(ConnectivityManager.java:264)
01-09 23:42:39.951: E/com.whooznear.android.ConnectActivity(1532): at com.whooznear.android.ConnectActivity.checkWifiStatus(ConnectActivity.java:214)
01-09 23:42:39.951: E/com.whooznear.android.ConnectActivity(1532): at com.whooznear.android.ConnectActivity.onCreate(ConnectActivity.java:60)
01-09 23:42:39.951: E/com.whooznear.android.ConnectActivity(1532): at android.app.Activity.performCreate(Activity.java:4397)
01-09 23:42:39.951: E/com.whooznear.android.ConnectActivity(1532): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048)
01-09 23:42:39.951: E/com.whooznear.android.ConnectActivity(1532): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1779)
01-09 23:42:39.951: E/com.whooznear.android.ConnectActivity(1532): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1831)
01-09 23:42:39.951: E/com.whooznear.android.ConnectActivity(1532): at android.app.ActivityThread.access$500(ActivityThread.java:122)
01-09 23:42:39.951: E/com.whooznear.android.ConnectActivity(1532): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1024)
01-09 23:42:39.951: E/com.whooznear.android.ConnectActivity(1532): at android.os.Handler.dispatchMessage(Handler.java:99)
01-09 23:42:39.951: E/com.whooznear.android.ConnectActivity(1532): at android.os.Looper.loop(Looper.java:132)
01-09 23:42:39.951: E/com.whooznear.android.ConnectActivity(1532): at android.app.ActivityThread.main(ActivityThread.java:4123)
01-09 23:42:39.951: E/com.whooznear.android.ConnectActivity(1532): at java.lang.reflect.Method.invokeNative(Native Method)
01-09 23:42:39.951: E/com.whooznear.android.ConnectActivity(1532): at java.lang.reflect.Method.invoke(Method.java:491)
01-09 23:42:39.951: E/com.whooznear.android.ConnectActivity(1532): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
01-09 23:42:39.951: E/com.whooznear.android.ConnectActivity(1532): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
01-09 23:42:39.951: E/com.whooznear.android.ConnectActivity(1532): at dalvik.system.NativeStart.main(Native Method)
01-09 23:42:39.991: I/ServiceServer(1532): java.net.SocketException: Permission denied
01-09 23:42:40.032: I/ConnectActivity(1532): Started at -1
01-09 23:42:40.041: W/dalvikvm(1532): threadid=9: thread exiting with uncaught exception (group=0x40 014760)
01-09 23:42:40.071: E/AndroidRuntime(1532): FATAL EXCEPTION: Thread-12
01-09 23:42:40.071: E/AndroidRuntime(1532): java.lang.NullPointerException
01-09 23:42:40.071: E/AndroidRuntime(1532): at com.whooznear.android.ServiceServer.serverThreadProc(ServiceServer.java:61)
01-09 23:42:40.071: E/AndroidRuntime(1532): at com.whooznear.android.ServiceServer.access$0(ServiceServer.java:57)
01-09 23:42:40.071: E/AndroidRuntime(1532): at com.whooznear.android.ServiceServer$1.run(ServiceServer.java:52)
01-09 23:42:40.693: D/dalvikvm(1532): GC_CONCURRENT freed 416K, 7% free 7200K/7687K, paused 6ms+27ms
01-09 23:42:41.041: E/com.whooznear.android.ConnectActivity(1532): Check Wifi Status Failed!
01-09 23:42:41.041: E/com.whooznear.android.ConnectActivity(1532): java.lang.SecurityException: ConnectivityService: Neither user 10036 nor current process has android.permission.ACCESS_NETWORK_STATE.
01-09 23:42:41.041: E/com.whooznear.android.ConnectActivity(1532): at android.os.Parcel.readException(Parcel.java:1321)
01-09 23:42:41.041: E/com.whooznear.android.ConnectActivity(1532): at android.os.Parcel.readException(Parcel.java:1275)
01-09 23:42:41.041: E/com.whooznear.android.ConnectActivity(1532): at android.net.IConnectivityManager$Stub$Proxy.getNetworkInfo(IConnectivityManager.java:469)
01-09 23:42:41.041: E/com.whooznear.android.ConnectActivity(1532): at android.net.ConnectivityManager.getNetworkInfo(ConnectivityManager.java:264)
01-09 23:42:41.041: E/com.whooznear.android.ConnectActivity(1532): at com.whooznear.android.ConnectActivity.checkWifiStatus(ConnectActivity.java:214)
01-09 23:42:41.041: E/com.whooznear.android.ConnectActivity(1532): at com.whooznear.android.ConnectActivity.onCreate(ConnectActivity.java:60)
01-09 23:42:41.041: E/com.whooznear.android.ConnectActivity(1532): at android.app.Activity.performCreate(Activity.java:4397)
01-09 23:42:41.041: E/com.whooznear.android.ConnectActivity(1532): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048)
01-09 23:42:41.041: E/com.whooznear.android.ConnectActivity(1532): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1779)
01-09 23:42:41.041: E/com.whooznear.android.ConnectActivity(1532): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1831)
01-09 23:42:41.041: E/com.whooznear.android.ConnectActivity(1532): at android.app.ActivityThread.access$500(ActivityThread.java:122)
01-09 23:42:41.041: E/com.whooznear.android.ConnectActivity(1532): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1024)
01-09 23:42:41.041: E/com.whooznear.android.ConnectActivity(1532): at android.os.Handler.dispatchMessage(Handler.java:99)
01-09 23:42:41.041: E/com.whooznear.android.ConnectActivity(1532): at android.os.Looper.loop(Looper.java:132)
01-09 23:42:41.041: E/com.whooznear.android.ConnectActivity(1532): at android.app.ActivityThread.main(ActivityThread.java:4123)
01-09 23:42:41.041: E/com.whooznear.android.ConnectActivity(1532): at java.lang.reflect.Method.invokeNative(Native Method)
01-09 23:42:41.041: E/com.whooznear.android.ConnectActivity(1532): at java.lang.reflect.Method.invoke(Method.java:491)
01-09 23:42:41.041: E/com.whooznear.android.ConnectActivity(1532): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
01-09 23:42:41.041: E/com.whooznear.android.ConnectActivity(1532): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
01-09 23:42:41.041: E/com.whooznear.android.ConnectActivity(1532): at dalvik.system.NativeStart.main(Native Method)
01-09 23:42:41.151: I/ServiceServer(1532): java.net.SocketException: Permission denied
01-09 23:44:09.541: I/ActivityThread(1575): Pub com.whooznear.android: com.whooznear.android.ProfileProvider
01-09 23:44:10.054: D/dalvikvm(1575): GC_FOR_ALLOC freed 40K, 4% free 6337K/6595K, paused 247ms
01-09 23:44:10.112: I/dalvikvm-heap(1575): Grow heap (frag case) to 6.805MB for 588816-byte allocation
01-09 23:44:10.422: D/dalvikvm(1575): GC_FOR_ALLOC freed 8K, 4% free 6903K/7175K, paused 265ms
01-09 23:44:10.791: D/dalvikvm(1575): GC_CONCURRENT freed <1K, 4% free 6903K/7175K, paused 72ms+3ms
01-09 23:44:14.162: D/dalvikvm(1575): GC_FOR_ALLOC freed 603K, 11% free 6667K/7431K, paused 68ms
01-09 23:44:14.334: D/dalvikvm(1575): GC_CONCURRENT freed <1K, 4% free 7168K/7431K, paused 6ms+16ms
01-09 23:44:14.673: W/Profile(1575): Invalid profile, java.lang.ArrayIndexOutOfBoundsException: index=1 length=1
01-09 23:44:19.782: E/com.whooznear.android.ConnectActivity(1575): Check Wifi Status Failed!
01-09 23:44:19.782: E/com.whooznear.android.ConnectActivity(1575): java.lang.SecurityException: ConnectivityService: Neither user 10036 nor current process has android.permission.ACCESS_NETWORK_STATE.
01-09 23:44:19.782: E/com.whooznear.android.ConnectActivity(1575): at android.os.Parcel.readException(Parcel.java:1321)
01-09 23:44:19.782: E/com.whooznear.android.ConnectActivity(1575): at android.os.Parcel.readException(Parcel.java:1275)
01-09 23:44:19.782: E/com.whooznear.android.ConnectActivity(1575): at android.net.IConnectivityManager$Stub$Proxy.getNetworkInfo(IConnectivityManager.java:469)
01-09 23:44:19.782: E/com.whooznear.android.ConnectActivity(1575): at android.net.ConnectivityManager.getNetworkInfo(ConnectivityManager.java:264)
01-09 23:44:19.782: E/com.whooznear.android.ConnectActivity(1575): at com.whooznear.android.ConnectActivity.checkWifiStatus(ConnectActivity.java:214)
01-09 23:44:19.782: E/com.whooznear.android.ConnectActivity(1575): at com.whooznear.android.ConnectActivity.onCreate(ConnectActivity.java:60)
01-09 23:44:19.782: E/com.whooznear.android.ConnectActivity(1575): at android.app.Activity.performCreate(Activity.java:4397)
01-09 23:44:19.782: E/com.whooznear.android.ConnectActivity(1575): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048)
01-09 23:44:19.782: E/com.whooznear.android.ConnectActivity(1575): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1779)
01-09 23:44:19.782: E/com.whooznear.android.ConnectActivity(1575): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1831)
01-09 23:44:19.782: E/com.whooznear.android.ConnectActivity(1575): at android.app.ActivityThread.access$500(ActivityThread.java:122)
01-09 23:44:19.782: E/com.whooznear.android.ConnectActivity(1575): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1024)
01-09 23:44:19.782: E/com.whooznear.android.ConnectActivity(1575): at android.os.Handler.dispatchMessage(Handler.java:99)
01-09 23:44:19.782: E/com.whooznear.android.ConnectActivity(1575): at android.os.Looper.loop(Looper.java:132)
01-09 23:44:19.782: E/com.whooznear.android.ConnectActivity(1575): at android.app.ActivityThread.main(ActivityThread.java:4123)
01-09 23:44:19.782: E/com.whooznear.android.ConnectActivity(1575): at java.lang.reflect.Method.invokeNative(Native Method)
01-09 23:44:19.782: E/com.whooznear.android.ConnectActivity(1575): at java.lang.reflect.Method.invoke(Method.java:491)
01-09 23:44:19.782: E/com.whooznear.android.ConnectActivity(1575): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
01-09 23:44:19.782: E/com.whooznear.android.ConnectActivity(1575): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
01-09 23:44:19.782: E/com.whooznear.android.ConnectActivity(1575): at dalvik.system.NativeStart.main(Native Method)
01-09 23:44:19.831: I/ServiceServer(1575): java.net.SocketException: Permission denied
01-09 23:44:19.861: I/ConnectActivity(1575): Started at -1
01-09 23:44:19.872: W/dalvikvm(1575): threadid=10: thread exiting with uncaught exception (group=0x40 014760)
01-09 23:44:19.872: E/AndroidRuntime(1575): FATAL EXCEPTION: Thread-13
01-09 23:44:19.872: E/AndroidRuntime(1575): java.lang.NullPointerException
01-09 23:44:19.872: E/AndroidRuntime(1575): at com.whooznear.android.ServiceServer.serverThreadProc(ServiceServer.java:61)
01-09 23:44:19.872: E/AndroidRuntime(1575): at com.whooznear.android.ServiceServer.access$0(ServiceServer.java:57)
01-09 23:44:19.872: E/AndroidRuntime(1575): at com.whooznear.android.ServiceServer$1.run(ServiceServer.java:52)
01-09 23:44:20.242: D/dalvikvm(1575): GC_CONCURRENT freed 415K, 7% free 7200K/7687K, paused 6ms+18ms
01-09 23:44:23.991: I/Process(1575): Sending signal. PID: 1575 SIG: 9
01-09 23:45:38.371: I/ActivityThread(1619): Pub com.whooznear.android: com.whooznear.android.ProfileProvider
01-09 23:45:38.651: D/dalvikvm(1619): GC_FOR_ALLOC freed 41K, 4% free 6337K/6595K, paused 91ms
01-09 23:45:38.671: I/dalvikvm-heap(1619): Grow heap (frag case) to 6.805MB for 588816-byte allocation
01-09 23:45:38.9 01: D/dalvikvm(1619): GC_FOR_ALLOC freed 8K, 4% free 6903K/7175K, paused 168ms
01-09 23:45:39.182: D/dalvikvm(1619): GC_CONCURRENT freed <1K, 4% free 6903K/7175K, paused 6ms+27ms
01-09 23:45:42.671: D/dalvikvm(1619): GC_FOR_ALLOC freed 603K, 11% free 6667K/7431K, paused 71ms
01-09 23:45:42.831: D/dalvikvm(1619): GC_CONCURRENT freed <1K, 4% free 7168K/7431K, paused 6ms+4ms
01-09 23:45:43.192: W/Profile(1619): Invalid profile, java.lang.ArrayIndexOutOfBoundsException: index=1 length=1
01-09 23:45:49.541: W/Profile(1619): Invalid profile, java.lang.ArrayIndexOutOfBoundsException: index=1 length=1
01-09 23:45:49.821: D/dalvikvm(1619): GC_CONCURRENT freed 389K, 7% free 7214K/7687K, paused 6ms+6ms
01-09 23:45:55.831: W/Profile(1619): Invalid profile, java.lang.ArrayIndexOutOfBoundsException: index=1 length=1
01-09 23:45:57.022: D/dalvikvm(1619): GC_CONCURRENT freed 115K, 3% free 7549K/7751K, paused 8ms+21ms
01-09 23:50:58.672: W/Profile(1619): Invalid profile, java.lang.ArrayIndexOutOfBoundsException: index=1 length=1
01-09 23:57:17.532: W/Profile(1619): Invalid profile, java.lang.ArrayIndexOutOfBoundsException: index=1 length=1
01-09 23:57:18.632: D/dalvikvm(1619): GC_CONCURRENT freed 130K, 3% free 7857K/8071K, paused 10ms+7ms
01-10 00:08:48.752: I/ActivityThread(1662): Pub com.whooznear.android: com.whooznear.android.ProfileProvider
01-10 00:08:49.2 01: D/dalvikvm(1662): GC_FOR_ALLOC freed 42K, 4% free 6336K/6595K, paused 198ms
01-10 00:08:49.241: I/dalvikvm-heap(1662): Grow heap (frag case) to 6.805MB for 588816-byte allocation
01-10 00:08:49.471: D/dalvikvm(1662): GC_FOR_ALLOC freed 8K, 4% free 6903K/7175K, paused 196ms
01-10 00:08:49.712: D/dalvikvm(1662): GC_CONCURRENT freed <1K, 4% free 6903K/7175K, paused 7ms+3ms
01-10 00:08:53.211: D/dalvikvm(1662): GC_FOR_ALLOC freed 603K, 11% free 6666K/7431K, paused 69ms
01-10 00:08:53.391: D/dalvikvm(1662): GC_CONCURRENT freed <1K, 4% free 7167K/7431K, paused 6ms+26ms
01-10 00:08:53.732: W/Profile(1662): Invalid profile, java.lang.ArrayIndexOutOfBoundsException: index=1 length=1
01-10 00:09:34.981: E/com.whooznear.android.ConnectActivity(1662): Check Wifi Status Failed!
01-10 00:09:34.981: E/com.whooznear.android.ConnectActivity(1662): java.lang.SecurityException: ConnectivityService: Neither user 10036 nor current process has android.permission.ACCESS_NETWORK_STATE.
01-10 00:09:34.981: E/com.whooznear.android.ConnectActivity(1662): at android.os.Parcel.readException(Parcel.java:1321)
01-10 00:09:34.981: E/com.whooznear.android.ConnectActivity(1662): at android.os.Parcel.readException(Parcel.java:1275)
01-10 00:09:34.981: E/com.whooznear.android.ConnectActivity(1662): at android.net.IConnectivityManager$Stub$Proxy.getNetworkInfo(IConnectivityManager.java:469)
01-10 00:09:34.981: E/com.whooznear.android.ConnectActivity(1662): at android.net.ConnectivityManager.getNetworkInfo(ConnectivityManager.java:264)
01-10 00:09:34.981: E/com.whooznear.android.ConnectActivity(1662): at com.whooznear.android.ConnectActivity.checkWifiStatus(ConnectActivity.java:214)
01-10 00:09:34.981: E/com.whooznear.android.ConnectActivity(1662): at com.whooznear.android.ConnectActivity.onCreate(ConnectActivity.java:60)
01-10 00:09:34.981: E/com.whooznear.android.ConnectActivity(1662): at android.app.Activity.performCreate(Activity.java:4397)
01-10 00:09:34.981: E/com.whooznear.android.ConnectActivity(1662): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048)
01-10 00:09:34.981: E/com.whooznear.android.ConnectActivity(1662): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1779)
01-10 00:09:34.981: E/com.whooznear.android.ConnectActivity(1662): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1831)
01-10 00:09:34.981: E/com.whooznear.android.ConnectActivity(1662): at android.app.ActivityThread.access$500(ActivityThread.java:122)
01-10 00:09:34.981: E/com.whooznear.android.ConnectActivity(1662): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1024)
01-10 00:09:34.981: E/com.whooznear.android.ConnectActivity(1662): at android.os.Handler.dispatchMessage(Handler.java:99)
01-10 00:09:34.981: E/com.whooznear.android.ConnectActivity(1662): at android.os.Looper.loop(Looper.java:132)
01-10 00:09:34.981: E/com.whooznear.android.ConnectActivity(1662): at android.app.ActivityThread.main(ActivityThread.java:4123)
01-10 00:09:34.981: E/com.whooznear.android.ConnectActivity(1662): at java.lang.reflect.Method.invokeNative(Native Method)
01-10 00:09:34.981: E/com.whooznear.android.ConnectActivity(1662): at java.lang.reflect.Method.invoke(Method.java:491)
01-10 00:09:34.981: E/com.whooznear.android.ConnectActivity(1662): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
01-10 00:09:34.981: E/com.whooznear.android.ConnectActivity(1662): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
01-10 00:09:34.981: E/com.whooznear.android.ConnectActivity(1662): at dalvik.system.NativeStart.main(Native Method)
01-10 00:09:35.051: I/ServiceServer(1662): java.net.SocketException: Permission denied
01-10 00:09:35.051: I/ConnectActivity(1662): Started at -1
01-10 00:09:35.081: W/dalvikvm(1662): threadid=9: thread exiting with uncaught exception (group=0x40 014760)
01-10 00:09:35.081: E/AndroidRuntime(1662): FATAL EXCEPTION: Thread-12
01-10 00:09:35.081: E/AndroidRuntime(1662): java.lang.NullPointerException
01-10 00:09:35.081: E/AndroidRuntime(1662): at com.whooznear.android.ServiceServer.serverThreadProc(ServiceServer.java:61)
01-10 00:09:35.081: E/AndroidRuntime(1662): at com.whooznear.android.ServiceServer.access$0(ServiceServer.java:57)
01-10 00:09:35.081: E/AndroidRuntime(1662): at com.whooznear.android.ServiceServer$1.run(ServiceServer.java:52)
01-10 00:09:35.732: D/dalvikvm(1662): GC_CONCURRENT freed 416K, 7% free 72 01K/7687K, paused 7ms+278ms
01-10 00:09:52.712: I/ActivityThread(1699): Pub com.whooznear.android: com.whooznear.android.ProfileProvider
01-10 00:09:53.031: D/dalvikvm(1699): GC_FOR_ALLOC freed 42K, 4% free 6336K/6595K, paused 93ms
01-10 00:09:53.051: I/dalvikvm-heap(1699): Grow heap (frag case) to 6.805MB for 588816-byte allocation
01-10 00:09:53.171: D/dalvikvm(1699): GC_FOR_ALLOC freed 8K, 4% free 6903K/7175K, paused 79ms
01-10 00:09:53.431: D/dalvikvm(1699): GC_CONCURRENT freed <1K, 4% free 6903K/7175K, paused 5ms+3ms
01-10 00:09:56.832: D/dalvikvm(1699): GC_FOR_ALLOC freed 603K, 11% free 6666K/7431K, paused 82ms
01-10 00:09:57.031: D/dalvikvm(1699): GC_CONCURRENT freed <1K, 4% free 7167K/7431K, paused 12ms+14ms
01-10 00:09:57.381: W/Profile(1699): Invalid profile, java.lang.ArrayIndexOutOfBoundsException: index=1 length=1
最佳答案
01-09 23:42:39.951: E/com.whooznear.android.ConnectActivity(1532): Check Wifi Status Failed!
01-09 23:42:39.951: E/com.whooznear.android.ConnectActivity(1532): java.lang.SecurityException: ConnectivityService: Neither user 10036 nor current process has android.permission.ACCESS_NETWORK_STATE.
01-09 23:42:39.951: E/com.whooznear.android.ConnectActivity(1532): at android.os.Parcel.readException(Parcel.java:1321)
01-09 23:42:39.951: E/com.whooznear.android.ConnectActivity(1532): at android.os.Parcel.readException(Parcel.java:1275)
01-09 23:42:39.951: E/com.whooznear.android.ConnectActivity(1532): at android.net.IConnectivityManager$Stub$Proxy.getNetworkInfo(IConnectivityManager.java:469)
01-09 23:42:39.951: E/com.whooznear.android.ConnectActivity(1532): at android.net.ConnectivityManager.getNetworkInfo(ConnectivityManager.java:264)
01-09 23:42:39.951: E/com.whooznear.android.ConnectActivity(1532): at com.whooznear.android.ConnectActivity.checkWifiStatus(ConnectActivity.java:214)
01-09 23:42:39.951: E/com.whooznear.android.ConnectActivity(1532): at com.whooznear.android.ConnectActivity.onCreate(ConnectActivity.java:60)
您需要相应的用户权限来检查 wifi 状态(更具体地说是 ConnectivityManager API),将以下权限添加到您应用的 AndroidManifest.xml 中:
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<!-- Note that to us JmDNS, you also need the following permissions -->
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE"/>
试试看会发生什么,通过阅读您的代码,您可能遇到了一些其他问题。
关于android - 在 Android App 中列出 JmDNS 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8796746/
我正在尝试 jmDNS jar ,但是当我运行我的应用程序时,它会抛出类似 NoClassDefFoundError: javax.jmdns.JmDNS 的错误。 它从这一行抛出错误 jm
希望我的问题不是太愚蠢,但我遇到了以下问题...... 我正在将一个包含库 JmDNS 的 jar 导入到我的项目中。我的项目设置为像这样处理 JmDNS... setUp();
我正在使用 JmDNS 在网络中同一子网下的几台计算机中注册服务。然而,每次第二台机器启动并尝试注册服务时,其名称都会自动更改为“service_name(编号)”之类的名称。我认为发生这种情况是为了
我有一个我认为非常简单的问题。 我正在尝试使用 JmDNS 来广播我已经成功完成的服务,但是当应用程序暂停时,我想取消注册服务,然后在恢复应用程序时重新注册服务。 然而,我在执行此操作时遇到了问题。代
我已经能够获取 JmDNS 附带的示例来编译和运行,但是我无法获取任何类来发现我的服务。 我正在运行一个 Windows 环境,多台 PC 运行 VNC、SSH 和 Apache,我一直在尝试让 Jm
我正在尝试为 Android 应用程序和桌面应用程序之间的通信实现 JmDNS 发现。我遵循了以下教程: http://home.heeere.com/tech-androidjmdns.html A
我正在尝试使用 JmDNS 来检测网络上设备的添加和删除。添加工作正常,一旦设备各自的服务在 JmDNS 中注册,就会找到这些设备,但是,当设备从网络中删除时,它永远不会在 JmDNS 中注册。 我曾
我正在尝试实现一个类来发现网络上的服务。我试过使用 Android's NSD它确实发现服务很好,但它只支持 API 级别 16 及更高级别,而且我似乎无法检索服务信息中的 txtRecord 字段(
使用jmdns 3.4.1,我可以看到局域网中机器发布的服务,我也可以创建一个服务并注册它,这样我就可以在我的机器上看到它。但是,当我在局域网的另一台机器上新建服务时,在我的机器上是看不到的。我在另一
我已经创建了 JmDNS 示例: public class Service { public static void main(String[] args) { try { J
已结束。此问题正在寻求书籍、工具、软件库等的推荐。它不满足Stack Overflow guidelines 。目前不接受答案。 我们不允许提出寻求书籍、工具、软件库等推荐的问题。您可以编辑问题,以便
我已经在我的 linux 电脑上使用 mdnsreponder(applebonjour) 为我的服务注册了子类型 .我正在尝试在我的 Galaxy 手机上使用 jmdns(这里我有 jmdns.ja
您好,我创建了示例 jmdns serviceListner,当我运行它时,它应该继续列出它找到的服务,但是通过这个我的程序,它在运行时列出了一些服务,之后它不列出任何服务。而且我的 google
我正在使用 ( http://jmdns.sourceforge.net/) 将发现添加到我们的应用程序中。它实际上在我的小型家庭网络上正常工作。但它在办公室的大型网络上失败了。我似乎记得读过,如果一
我在 Raspberry Pi 设备上启动并运行 JmDNS 时遇到问题。该应用程序在各种 x86 Linux 上运行良好,但在 Raspberry(运行“Raspbian GNU/Linux 8 (
我正在尝试让 JmDNS 在我的 android 程序中工作。我能够让它发现我想要的设备,但我不完全理解如何从 JmDNS 获取信息到启动 JmDNS 任务的对象。这是我的代码。 protected
我在让 JmDNS 与我的 Android AVD 一起工作时遇到了一些困难。我创建了 3 个应用程序。一个注册 ServiceListener 并记录任何 Activity 的 Android 应用
我正在用 Java(使用 Spark)开发一个 Web 应用程序,我希望它使用 JmDNS 以便能够在我的 Android 应用程序中找到此服务器。我按照 JmDNS page 中的步骤进行服务注册,
我正在通过其他运行 windows-xp 的机器创建 JmDNS 服务 JmDNS dns = JmDNS.create("localhost"); dns.regesterService("_sre
前言:从 SDK 级别 16 开始,Android 有一个内置的 Zeroconf 实现。除非青铜时代的兼容性是一个问题,否则不要再使用 jmDNS,而是使用 NsdManager。 前言 #2:Ns
我是一名优秀的程序员,十分优秀!