小编ezy*_*ezy的帖子

MainActivity已泄露最初绑定的ServiceConnection android.speech.SpeechRecognizer$Connection@414ee400

在我的应用程序中,我认识到用户说"退出"或"关闭",应用程序应关闭.有了这段代码

SpeechRecognizer sr;
Map<String, Integer> dictionary;
private static final int EXIT = 1;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    populateDictionary();
    SpeechRecognizer sr = SpeechRecognizer.createSpeechRecognizer(this);
    sr.setRecognitionListener(this);
    Intent voiceIntent = RecognizerIntent.getVoiceDetailsIntent(getApplicationContext());
    sr.startListening(voiceIntent);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

private void populateDictionary() {
    dictionary = new HashMap<String, Integer>();
    dictionary.put("exit", EXIT);
    dictionary.put("close", EXIT);
}

@Override
public void onResults(Bundle results) {
    ArrayList<String> …
Run Code Online (Sandbox Code Playgroud)

android speech-recognition serviceconnection

9
推荐指数
2
解决办法
2万
查看次数

具有 Maven 依赖系统范围的 ClassNotFoundException

我正在ClassNotFoundExceptionNoClassDefFoundError例外,当我尝试运行使用一个Maven定义依赖我的应用程序。

我使用以下声明将有关 jar 的 maven 依赖项添加到我的 pom.xml 文件中:

<dependency>
  <groupId>ldap</groupId>
  <artifactId>com.novell.ldap</artifactId>
  <systemPath>${local.lib.dir}/ldap.jar</systemPath>
  <scope>system</scope>
  <version>1</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)

jar 已正确添加到 Dependencies NetBeans 项目中

在此处输入图片说明

但是当我部署应用程序时,依赖项丢失了

java.lang.NoClassDefFoundError: com/novell/ldap/LDAPException
Run Code Online (Sandbox Code Playgroud)

java noclassdeffounderror maven

6
推荐指数
1
解决办法
7473
查看次数

Tensorflow 2.0 - 大数据集的 tf.estimator.DNNClassifier 训练

我正在尝试训练 DNNClassifier

    labels = ['BENIGN', 'Syn', 'UDPLag', 'UDP', 'LDAP', 'MSSQL', 'NetBIOS', 'WebDDoS']

    # Build a DNN
    classifier = tf.estimator.DNNClassifier(
    feature_columns=feature_columns,
    hidden_units=[30, 10],
    n_classes=len(labels),
    label_vocabulary=labels)

    def input_fn(features, labels, training=True, batch_size=32):
       '''
       An input function for training or evaluating
       '''
       # Convert the inputs to a Dataset.
       dataset = tf.data.Dataset.from_tensor_slices((dict(features), labels))
       # Shuffle and repeat if you are in training mode.
       if training:
          dataset = dataset.shuffle(1000).repeat()
       return dataset.batch(batch_size)

    # Train the model
    classifier.train(
    input_fn=lambda: input_fn(train_features, train_label, training=True),
    steps=5000)
Run Code Online (Sandbox Code Playgroud)

训练工作正常,直到使用更大的数据集

train_features.shape
>>> (15891114, …
Run Code Online (Sandbox Code Playgroud)

tensorflow tensorflow-datasets google-colaboratory tensorflow-estimator tensorflow2.0

6
推荐指数
1
解决办法
678
查看次数

添加标记时Android谷歌地图空指针异常

我做了一个简单的FragmentActivity显示谷歌地图,并使用标记显示当前位置和附近的地方.但现在我需要在另一个应用程序中使用该代码,我遇到了这个问题.

这是活动

private void updatePlaces(JSONArray jDestinationArray) throws JSONException{

    locMan = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
    Location lastLoc = locMan.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
    double lat = lastLoc.getLatitude();
    double lng = lastLoc.getLongitude();
    lastLatLng = new LatLng(lat, lng);

    Display display = getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    int width = size.x;
    int height = size.y;

    Builder boundsBuilder = new LatLngBounds.Builder();
    boundsBuilder.include(lastLatLng);

    markers = new HashMap<Marker,Object>();
    userMarker = map.addMarker(new MarkerOptions()
        .position(lastLatLng)
        .title("You are here")
        .icon(BitmapDescriptorFactory.fromResource(userIcon))
        .snippet("This is your last recorded location"));


    markers.put(userMarker, lastLatLng);
    for(int i=0; i<jDestinationArray.length(); i++){
        JSONObject destinationObject = …
Run Code Online (Sandbox Code Playgroud)

java android google-maps google-maps-markers

4
推荐指数
1
解决办法
4457
查看次数