小编Ank*_*rma的帖子

设置模拟位置时 GPS 提供商未知错误?

我正在尝试设置我的模拟位置,但是,我收到以下错误(提供商\'gps\'未知)并且不确定出了什么问题?

\n\n

我已经获得了在manifest.xml 中声明的所有权限以及所有参数。

\n\n

模拟定位法

\n\n
 //Initiates the method to set the phones location\n        private void setMockLocation() {\n          mLocationManager.removeTestProvider(LocationManager.GPS_PROVIDER);\n          mLocationManager.addTestProvider\n                    (\n                    LocationManager.GPS_PROVIDER,\n                    "requiresNetwork" == "",\n                    "requiresSatellite" == "",\n                    "requiresCell" == "",\n                    "hasMonetaryCost" == "",\n                    "supportsAltitude" == "",\n                    "supportsSpeed" == "",\n                    "supportsBearing" == "",\n\n                    android.location.Criteria.POWER_LOW,\n                    android.location.Criteria.ACCURACY_FINE\n                    );\n\n            Location newLocation = new Location(LocationManager.GPS_PROVIDER);\n\n            newLocation.setLatitude (32.4276462);\n            newLocation.setLongitude(-23.5509257);\n\n            newLocation.setAccuracy(500);\n\n            mLocationManager.setTestProviderEnabled\n                    (\n                            LocationManager.GPS_PROVIDER,\n                            true\n                    );\n\n            mLocationManager.setTestProviderStatus\n                    (\n                            LocationManager.GPS_PROVIDER,\n                            LocationProvider.AVAILABLE,\n                            null,\n                            System.currentTimeMillis()\n                    );\n\n            mLocationManager.setTestProviderLocation\n                    (\n                            LocationManager.GPS_PROVIDER,\n                            newLocation\n                    );\n        }\n
Run Code Online (Sandbox Code Playgroud)\n\n

错误信息

\n\n
\n
5-09 16:28:45.577 …
Run Code Online (Sandbox Code Playgroud)

java error-handling gps android location

5
推荐指数
0
解决办法
605
查看次数

SetTestProviderLocation错误...尽管所有参数都没有设置位置?

我试图设置我的手机的位置但它会抛出一个错误,说我错过了一些值?但是,这两个都是在我的方法中定义的,所以不确定我必须做什么......有什么想法吗?有解释吗?

类:

   //Initiates the method to set the phones location
    private void setMockLocation() {
      mLocationManager.removeTestProvider(LocationManager.GPS_PROVIDER);
      mLocationManager.addTestProvider
                (
                LocationManager.GPS_PROVIDER,
                "requiresNetwork" == "",
                "requiresSatellite" == "",
                "requiresCell" == "",
                "hasMonetaryCost" == "",
                "supportsAltitude" == "",
                "supportsSpeed" == "",
                "supportsBearing" == "",

                android.location.Criteria.POWER_LOW,
                android.location.Criteria.ACCURACY_FINE
                );

        Location newLocation = new Location(LocationManager.GPS_PROVIDER);

        newLocation.setLatitude (55.9500);
        newLocation.setLongitude(3.1833);

        newLocation.setAccuracy(500);

        mLocationManager.setTestProviderEnabled
                (
                        LocationManager.GPS_PROVIDER,
                        true
                );

        mLocationManager.setTestProviderStatus
                (
                        LocationManager.GPS_PROVIDER,
                        LocationProvider.AVAILABLE,
                        null,
                        System.currentTimeMillis()
                );

        mLocationManager.setTestProviderLocation
                (
                        LocationManager.GPS_PROVIDER,
                        newLocation
                );
    }
Run Code Online (Sandbox Code Playgroud)

错误:

04-28 19:52:13.716  17289-17289/com.example.ankhit.saveme E/AndroidRuntime? FATAL EXCEPTION: main
    java.lang.IllegalArgumentException: Incomplete location …
Run Code Online (Sandbox Code Playgroud)

java android mocking geolocation locationmanager

2
推荐指数
1
解决办法
3357
查看次数

在StringBuilder中附加逗号

我有一个小问题,我的代码工作,并向我发送经度和纬度的输出.我只想用逗号和空格来分隔textview中的值.我不想要行分隔符.

我得到的:32.67543-55.986454

我想要的:32.67543,-55.986454(逗号和空格)

有任何想法吗?

码:

/**
 * After completing background task Dismiss the progress dialog
 * *
 */
protected void onPostExecute(JSONObject product) {
    if (product != null) {
        // product with this pid found
        // Edit Text
        lblDummyLocation = (TextView) findViewById(R.id.lblDummyLocation);

        StringBuilder jsonStringBuilder = new StringBuilder(); //Create StringBuilder for concatenation of JSON results

        // display profile data in EditText
        try {
            //txtMessage.setText(product.getString(TAG_FIRSTNAME));  //Don't set the text here
            jsonStringBuilder.append(product.getString(TAG_LATITUDE)); //Concatenate each separate item
            jsonStringBuilder.append(System.getProperty("line.separator"));
        } catch (JSONException e) {
            e.printStackTrace();
        } …
Run Code Online (Sandbox Code Playgroud)

java stringbuilder android json comma

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