我正在尝试运行使用此库的示例pcsc项目.
运行它时,我收到以下错误
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/lang3/StringUtils
at com.github.devnied.emvnfccard.enums.EmvCardScheme.<init>(EmvCardScheme.java:97)
at com.github.devnied.emvnfccard.enums.EmvCardScheme.<clinit>(EmvCardScheme.java:32)
at com.github.devnied.emvnfccard.parser.EmvParser.readWithAID(EmvParser.java:277)
at com.github.devnied.emvnfccard.parser.EmvParser.readEmvCard(EmvParser.java:120)
at com.github.devnied.emvpcsccard.Main.main(Main.java:64)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang3.StringUtils
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 5 more
Run Code Online (Sandbox Code Playgroud)
我在libs和类路径中添加了commons-lang-2.6.jar&commons-lang3-3.1-sources.jar.我仍然得到这个错误
码
public static void main(final String[] args) throws CardException, CommunicationException {
Main pcsc = new Main();
CardTerminal ct = pcsc.selectCardTerminal();
Card c = null;
if (ct != null) {
c = …Run Code Online (Sandbox Code Playgroud) 我正在使用Retrofit2和RxJava2CallAdapterFactory.
我使用的API总是将状态代码返回为200,对于成功和响应JSON字符串,JSON结构完全不同.由于状态代码始终为200,因此始终调用onResponse()方法.因此,我无法在错误条件下从JSON中提取错误消息.
解决方案1:
我ScalarsConverterFactory用来获取响应String并手动使用Gson来解析响应.
如何在不使用GSON或android中的任何其他库的情况下使用retrofit获取响应
这个解决方案的问题:我打算使用RxJava2CallAdapterFactory,因为改进方法应该返回DataModel Class.
我需要找到解决此问题的最佳解决方案,我可以继续从Retrofit方法返回数据模型类,并以某种方式从响应中识别错误条件(确定响应JSON与数据模型不匹配)然后解析错误JSON成数据模型.
改造客户
public static Retrofit getClient(String url) {
if (apiClient == null) {
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
OkHttpClient httpClient = new OkHttpClient.Builder().addInterceptor(interceptor).build();
apiClient = new Retrofit.Builder()
.baseUrl(url)
/*addCallAdapterFactory for RX Recyclerviews*/
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
/* add ScalarsConverterFactory to get json string as response */
// .addConverterFactory(ScalarsConverterFactory.create())
.addConverterFactory(GsonConverterFactory.create())
// .addConverterFactory(GsonConverterFactory.create(gson))
.client(httpClient)
.build();
}
return apiClient;
}
Run Code Online (Sandbox Code Playgroud)
方法
public static void getLoginAPIResponse(String username, String password, String sourceId, String uuid, final …Run Code Online (Sandbox Code Playgroud) 我能够拉,但无法git推
$ git push -u origin master
Counting objects: 2031, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (1367/1367), done.
remote: fatal: early EOF
Writing objects: 100% (2031/2031), 34.33 MiB | 100.00 KiB/s, done.
Total 2031 (delta 659), reused 1056 (delta 324)
error: unpack failed: index-pack abnormal exit
To https://*********.git
! [remote rejected] master -> master (unpacker error)
error: failed to push some refs to 'https://*********
Run Code Online (Sandbox Code Playgroud)
我试过了 :
我已经提到了以下链接,但没有什么对我有用
我正在尝试使用ACR1281U NFC标签阅读器使用此示例在Android设备上进行主机卡仿真.
这是我想要的那种应用程序.
根据Android文档和示例,需要在Android项目中注册AID:
<host-apdu-service xmlns:android="http://schemas.android.com/apk/res/android"
android:description="@string/servicedesc"
android:requireDeviceUnlock="false">
<aid-group android:description="@string/aiddescription"
android:category="other">
<aid-filter android:name="F0010203040506"/>
<aid-filter android:name="F0394148148100"/>
</aid-group>
</host-apdu-service>
Run Code Online (Sandbox Code Playgroud)
我怎么知道我需要在我的Android应用程序中注册哪个AID,以便读者可以阅读HCE Android应用程序?
这是我发布的另一个相同的问题:没有支持的卡终端找到ARC1281U nfc读卡器
我已经提到了以下链接,但没有太多帮助:
请帮助,因为HCE上的资源非常少!
该示例使用F0010203040506SELECT(通过AID)命令中的AID,但我的ACR128阅读器无法读取HCE设备.
private static final byte[] CLA_INS_P1_P2 = { 0x00, (byte)0xA4, 0x04, 0x00 };
private static final byte[] AID_ANDROID = { (byte)0xF0, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 };
private byte[] createSelectAidApdu(byte[] aid) {
byte[] result = new byte[6 …Run Code Online (Sandbox Code Playgroud) 我使用webview加载html页面和网址.
我想仅在互联网可用或网页视图缓存网址内容时才加载网址.
如何检查是否缓存了URL而无需在某个外部路径上创建自己的缓存.
WebSettings ws = wv.getSettings();
ws.setJavaScriptEnabled(true);
ws.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
wv.setOnTouchListener(this);
wv.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (!url.contains("http")) {
view.loadUrl(url);
} else {
if (Utils.isConnectingToInternet(thisActivity)) {
view.loadUrl(url);
}
}
view.loadUrl(url);
return false;
}
Run Code Online (Sandbox Code Playgroud)
我提到过:
我知道这是一个有点重复的问题.我已经回顾了关于SO和其他几个网站的各种问题,但找不到满足我需求的单一答案.
需求
1)我有X,Y坐标,我想创建MotionEvent并将其发送到最顶层的活动/视图.
2)我必须在我自己的应用程序中注入它.因此不应该要求Inject_Events权限.
3)虽然我有坐标,我不知道,活动或视图在那个位置.所以Activity.dispatchTouchEvent对我不起作用..(view.dispatchTouchEvent可以工作,但我不知道视图).
4)仪器也无济于事,因为它们没有单一方法在x,y位置注入触摸事件.
5)InputManager有隐藏方法injectInputEvent但我不知道如何访问injectInputEvent并编译它?
任何帮助赞赏!
我试图使用我的 android 应用程序中的标签进行打印,该应用程序使用wifi命令Brother QL-720NW 标签打印机。由于我在打印机上执行了恢复出厂设置,因此出现此错误
问题: ERROR_WRONG_LABEL(意味着在 sdk 指南中指定了错误的卷筒)错误在打印命令中被抛出,因为我在打印机上执行了恢复出厂设置。
代码:
void printTemplateSample()
{
Printer myPrinter = new Printer();
PrinterInfo myPrinterInfo = new PrinterInfo();
try{
// Retrieve printer informations
myPrinterInfo = myPrinter.getPrinterInfo();
// Set printer informations
myPrinterInfo.printerModel = PrinterInfo.Model.QL_720NW;
myPrinterInfo.port=PrinterInfo.Port.NET;
myPrinterInfo.printMode=PrinterInfo.PrintMode.FIT_TO_PAGE;
// :
myPrinterInfo.paperSize = PrinterInfo.PaperSize.A4;
myPrinterInfo.ipAddress="192.168.1.13";
myPrinterInfo.macAddress="00:80:92:BD:35:7D";
myPrinter.setPrinterInfo(myPrinterInfo);
// Start creating P-touch Template command print data
// myPrinter.startPTTPrint(1, null);
Boolean val= myPrinter.startPTTPrint(6, null);
Log.i("print", "startPTTPrint "+val);
// Replace text
myPrinter.replaceText("abcde");
// myPrinter.replaceText("12345");
// Trasmit P-touch Template …Run Code Online (Sandbox Code Playgroud) 我有一个保存的地理位置(纬度,经度)。当用户按下应用程序中的操作按钮时,当前位置被记录下来。
我想检查当前的纬度、经度(我拥有的)是否落在圆形地理围栏(我拥有的中心地理点)中。
我不想在 Google 地图上创建地理围栏。我只想检查地理定位是否属于地理围栏。
当精度小于 20 时,我用来获取当前地理位置的代码:
public class CreatePlaceActivity extends Fragment implements
OnClickListener,
GoogleApiClient.ConnectionCallbacks,
GoogleApiClient.OnConnectionFailedListener, LocationListener {
private Button cancelBtn, submitBtn;
public boolean geoLocationCheck = false;
private String TAG = "CreatePlaceActivity";
public CreatePlaceActivity() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.create_place_screen,
container, false);
submitBtn = (Button) rootView.findViewById(R.id.submit_btn_id);
submitBtn.setTypeface(typeface);
submitBtn.setOnClickListener(this);
cancelBtn = (Button) rootView.findViewById(R.id.cancel_btn_id);
cancelBtn.setOnClickListener(this);
setlocationClient();
return rootView;
}
private void setlocationClient() {
int resp = GooglePlayServicesUtil
.isGooglePlayServicesAvailable(getActivity());
if …Run Code Online (Sandbox Code Playgroud) 接下来我在 xml 中添加了 nextFocus 值。
但是,根据未成年人复选框值的状态,一个编辑文本是可见的还是不可见的。所以我需要动态地在 YYYY editext 之后将焦点集中在它上面。但动态地 requestFocus() 不起作用。
单击下一步时我需要做什么
此电子邮件视图仅在未选中 18 岁以下复选框时可见。
在 YYYY edittext 之后单击下一步按钮时会发生什么:控制转到用户名 Edittext。我无法在 xml 中使用 FocusNext,因为每当电子邮件文本视图消失时应用程序就会崩溃
dobYearEt.setOnEditorActionListener(new EditText.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
Log.i("focus","on yyyy");
if (actionId == EditorInfo.IME_ACTION_DONE ||
actionId == EditorInfo.IME_ACTION_NEXT) {
Log.i("focus",isUnderAge+"");
if(isUnderAge){
username_reg_ev_dob_row.setFocusableInTouchMode(true);
username_reg_ev_dob_row.requestFocus();
}else{
// NOTHING HAPPENS
// email_ev.setFocusableInTouchMode(true);
// dobYearEt.clearFocus();
email_ev.requestFocus();
// InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
// mgr.showSoftInput(email_ev, InputMethodManager.SHOW_IMPLICIT);
}
return false;
}
Run Code Online (Sandbox Code Playgroud)
xml
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/register"
android:layout_marginLeft="@dimen/sign_up_left_right_margin" …Run Code Online (Sandbox Code Playgroud) 我正在对高十进制精度 BigDecimal 对象进行计算。
我正在使用需要双精度参数的第三方库。当我尝试将其转换为 double 时,我得到的是指数格式而不是小数格式的值。
Run Code Online (Sandbox Code Playgroud)BigDecimal 0.000035000000000 Double 3.5E-5
BigDecimal bd;
BigDecimal(0.0000349999999995631583260546904057264328002929687500);
bd= bd.setScale(15,BigDecimal.ROUND_CEILING);
Log.i("bd","bd "+bd.toPlainString());
Log.i("bd","double"+bd.doubleValue());
Run Code Online (Sandbox Code Playgroud)
我发现了多种方法可以将这个 3.5E-5 值转换为正确的十进制点数,但仅限于字符串格式。而我需要双倍的价值
能够在 String 对象中没有指数但不是双
DecimalFormat df = new DecimalFormat("#");
df.setMaximumFractionDigits(16);
String test=df.format(bd,doubleValue());
System.out.println("op2 "+test);
Double test1=Double.parseDouble(test);
System.out.println("op2 "+test1);
Run Code Online (Sandbox Code Playgroud)
输出 op2 .000035 op2 3.5E-5
自从几天以来,我一直在努力寻找解决方案,因为我无法控制需要值加倍的 3rd 方库
推荐链接
我的问题与这些链接不同,我不希望 double 作为没有指数的字符串,而我只希望它采用 double 格式。
编辑
如果传递的 double 值是指数格式,则基于 NDK 的库将进一步对此对象进行计算,这将导致更多的小数点和更大的指数值。所以,我想传递一个没有 E 的简单 double
我有以下问题:
当我点击我的地图标记(使用谷歌地图v3)时,我收到此错误:
"由于缺少_cordovaNative,因此退回PROMPT模式.预计Android 3.2及更低版本."
我该怎么办?
在不安全的模式下使用cordova 3.0.0和chrome非常感谢你
我正在尝试从我的pcsc java代码中读取卡UID/HCE android设备UID.但我收到以下错误
javax.smartcardio.CardException: sun.security.smartcardio.PCSCException: Unknown error 0x1f
Run Code Online (Sandbox Code Playgroud)
虽然当我尝试获取UID时我能够获得ATS位但是我得到了这个错误.我从这里提到了我的代码
码
import java.io.Console;
import java.util.List;
import java.util.ListIterator;
import java.util.Scanner;
import javax.smartcardio.ATR;
import javax.smartcardio.Card;
import javax.smartcardio.CardChannel;
import javax.smartcardio.CardException;
import javax.smartcardio.CardTerminal;
import javax.smartcardio.CommandAPDU;
import javax.smartcardio.ResponseAPDU;
import javax.smartcardio.TerminalFactory;
public class PCSC {
private byte[] atr = null;
private String protocol = null;
private byte[] historical = null;
public CardTerminal selectCardTerminal() {
try {
// show the list of available terminals
TerminalFactory factory = TerminalFactory.getDefault();
List<CardTerminal> terminals = factory.terminals().list();
ListIterator<CardTerminal> terminalsIterator …Run Code Online (Sandbox Code Playgroud)