我想使用SharedPreferences保存/调用整数数组,这可能吗?
我在计算两个地理点之间的距离时遇到问题.
地理位置是:
position1 = mapView.getProjection().fromPixels(
(int) e.getX(),
(int) e.getY());
Run Code Online (Sandbox Code Playgroud)
而另一个
double lat = 35.1064;
double lng = 22.556412;
GeoPoint position2 = new GeoPoint((int)(lat * 1E6), (int)(lng * 1E6));
Run Code Online (Sandbox Code Playgroud)
然后我创建了两个位置:
Location loc = new Location("");
loc.setLatitude(position1.getLatitudeE6());
loc.setLongitude(position1.getLongitudeE6());
Location loc2 = new Location("");
loc.setLatitude(position2.getLatitudeE6());
loc.setLongitude(position2.getLongitudeE6());
Run Code Online (Sandbox Code Playgroud)
然后我计算距离:
float distance = loc.distanceTo(loc2);
Run Code Online (Sandbox Code Playgroud)
我围绕它:
Math.round(distance);
Run Code Online (Sandbox Code Playgroud)
但我得到的结果如下:
1.4331783E7
我究竟做错了什么?
我想使用Java在Android中拆分String.我以前做过这个,但现在我得到了这个例外
11-20 17:57:37.665: ERROR/AndroidRuntime(25423): java.util.regex.PatternSyntaxException: Syntax error U_REGEX_MISMATCHED_PAREN near index 1:
11-20 17:57:37.665: ERROR/AndroidRuntime(25423): (
11-20 17:57:37.665: ERROR/AndroidRuntime(25423): ^
Run Code Online (Sandbox Code Playgroud)
我的字符串就像
String mystring= "iamhere(32)";
Run Code Online (Sandbox Code Playgroud)
而且我只想保留"iamhere".
我用它拆分了
String[] seperation = mystring.Split("(");
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
我有两个类,我想将一个(地理点)变量从一个传递到另一个,这样我就可以计算用户当前位置和地理点之间的距离.
长话短说:
我的第一个类名为Session,第二个名为 - 它们位于同一个包中.
我在主类中声明变量为public.在触摸时,我将用户当前位置保存到名为userposition的(公共)地理点变量中.
然后在我使用的第二课
Session pass = new Session();
Run Code Online (Sandbox Code Playgroud)
创建Session的实例.之后我尝试检索用户位置变量:
Geopoint position = pass.userposition;
Run Code Online (Sandbox Code Playgroud)
但它继续返回null并抛出异常,即使我在主类上测试变量并且工作得很好......我在这里缺少什么?
Session的主要代码是:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.maps);
// Blah blah blah
// And here i declare the GestureDetector...I working with google maps.
Gest = new GestureDetector(new SimpleOnGestureListener());
mapView.getOverlays().add(new Overlay() {
@Override
public boolean onTouchEvent(MotionEvent e, MapView mapView) {
Gest.onTouchEvent(e);
return super.onTouchEvent(e, mapView);
}
});
Gest.setOnDoubleTapListener(new OnDoubleTapListener() {
@Override
public boolean onDoubleTap(MotionEvent e) {
// and in here …Run Code Online (Sandbox Code Playgroud) 我正在使用一个使用用户位置的应用程序.
我可以成功地询问用户wifi和gps启用.如您所知,您可以使用WiFi,但不能提供您的位置.
问题是我想要让用户启用wifi位置获取服务,如果它被禁用.我使用wifi管理器用于wifi和LOCATION_PROVIDERS_ALLOWED用于GPS.两者都很好用.
//provider variable code
String provider = Settings.Secure.getString(getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED);
//i use the string into an if statement
if (!provider.contains("gps")){
}
Run Code Online (Sandbox Code Playgroud)
我明白我可以将启用的提供程序转换为用逗号分隔的变量.它工作得很好..但"gps"是GPS的名称,但是WiFi的名称是什么?
我是Android开发人员已经有一段时间了,但我是adob的新手......
我有两个问题:
在我的应用程序中放置一个文本是否正确,通知用户他可以通过点击添加来支持我们?类似于"点击添加以支持我们!" 或者它是错误的admob政策,他们将关闭我的帐户.
另一个问题是,当我去admob网络时,我可以让我的应用程序从admob网络以外接收广告......我应该启用它们吗?
谢谢
我正在使用一个应用程序,我只需要从mysql服务器下载谷歌地图的一对坐标.我可以使用PHP和普通的httpost成功完成此操作但我的应用程序冻结了几秒钟,当我这样做.
我读到你需要使httppost asycronous,以避免冻结,直到服务器完成prossess并发送结果.
关键是我需要的结果是像普通的httpost一样的json数组.
例如,如果我有这个httppost.
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://www.yoursite.com/script.php");
try {
// Add your data
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("id", "12345"));
nameValuePairs.add(new BasicNameValuePair("stringdata", "AndDev is Cool!"));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
// Execute HTTP Post Request
HttpResponse response = httpclient.execute(httppost);
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
} catch (IOException e) {
// TODO Auto-generated catch block
}
String result11 = null;
// convert response to string
try {
BufferedReader reader = …Run Code Online (Sandbox Code Playgroud) 嗨,我刚刚在谷歌播放上传了一个应用程序,但我找不到它.
我搜索了标记没有,然后我用我的名字作为开发人员搜索谷歌播放,我发现只有一个旧的应用程序我上传.
然后我尝试使用包名搜索
http://market.android.com/details?id=[your app package name]
Run Code Online (Sandbox Code Playgroud)
什么都没有......有什么建议吗?
在开发者控制台中,一切看起来都很好,我的应用程
嗨,我有一个字符串看起来像这样10 -1 30 -2,我想读取空格之间的数字.我可以使用FOR语句和代码来完成此操作
Character.toString(myString.charAt(i));
Run Code Online (Sandbox Code Playgroud)
和
Integer.parseInt(myString);
Run Code Online (Sandbox Code Playgroud)
但是当我尝试读取负数如-1时我遇到了问题,我收到了错误消息:
09-09 13:06:49.630: ERROR/AndroidRuntime(3365): Caused by: java.lang.NumberFormatException: unable to parse '-' as integer
Run Code Online (Sandbox Code Playgroud)
任何想法如何解决这个?