我在使用Android定位系统的NETWORK提供商获取当前位置坐标时遇到了麻烦.
已经阅读了很多教程,并为我的项目实现了4或5个现有的类,所有这些都给了我最后的坐标但不是当前的坐标.
我很确定问题是我缺少的基本问题,但我无法理解究竟是什么.
我现在使用的代码:
这是我的主要活动
package com.example.locationtests;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.widget.TextView;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
GPSTracker mGPS = new GPSTracker(this);
TextView text = (TextView) findViewById(R.id.texts);
if(mGPS.canGetLocation ){
mGPS.getLocation();
text.setText("Lat"+mGPS.getLatitude()+"Lon"+mGPS.getLongitude());
}else{
text.setText("Unabletofind");
System.out.println("Unable");
}
}
@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;
}
}
Run Code Online (Sandbox Code Playgroud)
这是我用于跟踪的课程:
package com.example.locationtests;
import android.app.AlertDialog; …Run Code Online (Sandbox Code Playgroud) 我试图获得uUID的ble设备.我正在关注Android开发人员指南,到目前为止我只能得到设备名称和rssi.我试图得到Uuid的设备,扫描方法看起来像这样:
public void onLeScan(final BluetoothDevice device, int rssi,byte[] scanRecord) {
ParcelUuid[] myUUid =device.getUuids();
for(ParcelUuid a :myUUid){
Log.d("UUID",a.getUuid().toString());
}
String s = new String(scanRecord);
int len = scanRecord.length;
String scanRecords =new String(scanRecord) ;
deviceMap.put(device.getName().toString(), rssi);
Message msg = MainActivity.myHandler.obtainMessage();
Bundle bundle = new Bundle();
bundle.putCharSequence("dev_name", device.getName().toString());
bundle.putCharSequence("rssi", Integer.toString(rssi));
msg.setData(bundle);
MainActivity.myHandler.sendMessage(msg);
}
Run Code Online (Sandbox Code Playgroud)
返回 - btif_gattc_upstreams_evt:事件4096
我正在使用ZBar QR扫描仪为我的Android应用程序.一切运行正常,库和设置没有问题.问题是我想让ZBar只扫描QR码而不扫描条形码.
有办法吗?怎么样?
这是我的扫描活动代码:
import net.sourceforge.zbar.Config;
import net.sourceforge.zbar.Image;
import net.sourceforge.zbar.ImageScanner;
import net.sourceforge.zbar.Symbol;
import net.sourceforge.zbar.SymbolSet;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.res.Resources;
import android.graphics.Color;
import android.hardware.Camera;
import android.hardware.Camera.AutoFocusCallback;
import android.hardware.Camera.PreviewCallback;
import android.hardware.Camera.Size;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.TextView;
public class QRScanActivity extends Activity {
private Camera mCamera;
private CameraPreview mPreview;
private Handler autoFocusHandler;
TextView scanText;
Button scanButton;
ImageScanner scanner;
private boolean barcodeScanned = false;
private boolean …Run Code Online (Sandbox Code Playgroud) 我试图处理我的简单Android应用程序的Facebook集成登录.我遵循这个指南https://developers.facebook.com/docs/getting-started/facebook-sdk-for-android/3.0/并且everthing似乎很好,但我仍然得到异常:java.lang.NoClassDefFoundError:android .support.v4.content.LocalBroadcastManager
我知道有很多关于这个问题的类似问题就像这个java.lang.ClassNotFoundException在项目中没有改变之后但是升级eclipse android sdk 说我必须检查其他和导出选项卡中的java构建路径中的所有复选框但是我已经完成了已经和我仍然得到错误.